Implement the geometric random graph as a graphon.
Naive implementation $O(n^2)$:
def geometric_random_graph(radius):
return Graphon(lambda x,y: np.abs(x-y) <= radius)
Networkx inspired implementation $O(n)$
uses scipy.spatial and redefine draw function with:
kdtree = sp.spatial.cKDTree(coords) # Cannot provide generator.
edge_indexes = kdtree.query_pairs(radius, p)
edges = [(nodes[u], nodes[v]) for u, v in sorted(edge_indexes)]
return edges
link to cKDTree from scipy
link to networkx code
Implement the geometric random graph as a graphon.
Naive implementation$O(n^2)$ :
Networkx inspired implementation$O(n)$
uses
scipy.spatialand redefine draw function with:link to cKDTree from scipy
link to networkx code