To do it with numpy.random.rand
, generate the random array, threshold it with the probability you want, and then pass it to Graph.Adjacency
:
adj = numpy.random.rand(edges, edges)
adj[adj > 0.999] = 1 # sets everything over 0.999 to 1
adj[adj <= 0.999] = 0 # sets everything below to 0
graph = Graph.Adjacency(adj)
This generates a directed graph, where adj[i, j] tells you whether there's an edge from i -> j. If you want an undirected one instead, use Graph.Ajacency(adj, ADJ_UNDIRECTED)
- then there'll be an edge if either adj[i, j] == 1
or adj[j, i] == 1
.
This isn't guaranteed to give you exactly 100,000 edges - do you need that?