Extension to MeasureObjectNeighbors

So for the MeasureObjectNeighbors I see how the module does the first and second closest distance to the other objects. Could you extend this so it would measure pairwise distances of all objects and compute a min/median/mean/max of those distances? In the meantime, I’m going to do this manually with the X’s and Y’s of the objects. Can you suggest a program / script that can make this analysis easiest (e.g. Matlab, Python, R)? I’ve so far written a pseudo-R-code script to do this:

clusterlist = read.csv(x and y's of cents)
create distlist with cluster, cent1, cent2, distance btw
length(unique(clusterlist$cluster))=totalClusters
totalClustersVector = c(1:totalClusters)

for indexOfCluster in totalClusters {
	cluster = as.list(subset(clusterlist, clusterlist$cluster==indexOfCluster))
	for cent in cluster {
		slice clusters into cent and othercents
		subcluster = set of othercents
# othercents being all cents to the right of the current in the list 
		for othercent in subcluster {
			dist=distance(cent,othercent)
			add cluster, cent, othercent, and dist to distlist

Perhaps this second question is a bit off-topic but I figured I’d ask anyway since you guys and gals are so knowledgeable. Thanks.