Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate a random graph given the number of nodes and edges?

I am using python with igraph library:

from igraph import *
g = Graph()
g.add_vertices(4)
g.add_edges([(0,2),(1,2),(3,2)])
print g.betweenness()

I would like to generate a random graph with 10000 nodes and 100000 edges. The edges can be random. Please suggest a way to have random edges (using numpy.random.rand )

like image 293
Kush Jain Avatar asked Dec 03 '13 09:12

Kush Jain


1 Answers

Do you have to use numpy.random.rand? If not, just use Graph.Erdos_Renyi, which lets you specify the number of nodes and edges directly:

g = Graph.Erdos_Renyi(n=10000, m=100000)
like image 184
Tamás Avatar answered Oct 20 '22 08:10

Tamás