I hope I understood correctly what is this: it's automatically changed by the build...
[guess.git] / Test.py
blob574f4e6d02df7527cd71c19792bc96cb538270eb
1 def pairwiseDistance(_n1,_n2):
2 _p1 = _n1.dijkstraShortestPath(org)
3 _p2 = _n2.dijkstraShortestPath(org)
4 _p1.reverse()
5 _p2.reverse()
6 while (_p1[0] == _p2[0]):
7 _p1.pop(0)
8 _p2.pop(0)
9 if ((len(_p1) == 0) or (len(_p2) == 0)):
10 break
11 return len(_p1) + len(_p2)
13 def findAverage(_grp):
14 sum = 0
15 count = 0
16 for i in range(0,len(_grp)):
17 for j in range(i+1,len(_grp)):
18 sum = sum + pairwiseDistance(_grp[i],_grp[j])
19 count = count + 1
20 return sum / count
22 gps = (version != '0').groupAndSortBy(gp)
23 for z in gps:
24 avg = findAverage(z)
25 print str(z[0].gp) + " " + str(avg)