def _fast_construct_edges(G, radius, p):
 pos = nx.get_node_attributes(G, 'pos')
 (nodes, coords) = list(zip(*pos.items()))
 kdtree = KDTree(coords)
 edge_indexes = kdtree.query_pairs(radius, p)
 edges = ((nodes[u], nodes[v]) for (u, v) in edge_indexes)
 G.add_edges_from(edges)

def _fast_construct_edges ( G , radius , p ) : pos = nx . get_node_attributes ( G , 'pos' ) ( nodes , coords ) = list ( zip ( * pos . items ( ) ) ) kdtree = KDTree ( coords ) edge_indexes = kdtree . query_pairs ( radius , p ) edges = ( ( nodes [ u ] , nodes [ v ] ) for ( u , v ) in edge_indexes ) G . add_edges_from ( edges )
construct edges for random geometric graph .