@nodes_or_number(0)
def random_geometric_graph(n, radius, dim=2, pos=None, p=2):
 (n_name, nodes) = n
 G = nx.Graph()
 G.name = 'random_geometric_graph({}, {}, {})'.format(n, radius, dim)
 G.add_nodes_from(nodes)
 if (pos is None):
  pos = {v: [random.random() for i in range(dim)] for v in nodes}
 nx.set_node_attributes(G, 'pos', pos)
 if _is_scipy_available:
  _fast_construct_edges(G, radius, p)
 else:
  _slow_construct_edges(G, radius, p)
 return G

@ nodes_or_number ( 0 ) def random_geometric_graph ( n , radius , dim = 2 , pos = None , p = 2 ) : ( n_name , nodes ) = n G = nx . Graph ( ) G . name = 'random_geometric_graph({}, {}, {})' . format ( n , radius , dim ) G . add_nodes_from ( nodes ) if ( pos is None ) : pos = { v : [ random . random ( ) for i in range ( dim ) ] for v in nodes } nx . set_node_attributes ( G , 'pos' , pos ) if _is_scipy_available : _fast_construct_edges ( G , radius , p ) else : _slow_construct_edges ( G , radius , p ) return G
returns a random geometric graph in the unit cube .