Revision fa4a0a42 util/UnitDiskGraph.py
util/UnitDiskGraph.py  

2  2  
3  3 
import networkx as nx 
4  4 
from scipy import spatial 
5 
import code # code.interact(local=dict(globals(), **locals())) 

5  6  
6  7  
7  8 
class UnitDiskGraph: 
...  ...  
12  13 
def genereateGraphFromKDtree(self, points, radius): 
13  14 
tree = spatial.KDTree(points) 
14  15 
edges = tree.query_pairs(r=radius) 
16 
edges = [e+(1.0,) for e in edges] 

15  17 
G = nx.Graph() 
16  18 
#pos = {k:points[k] for k in range(0,len(points))} 
17 
G.add_edges_from(edges)


19 
G.add_weighted_edges_from(edges, weight='weight')


18  20 
return G 
19  21  
20  22 
def getGraph(self): 
Also available in: Unified diff