416E64726577
416E64726577

Reputation: 2214

Algorithm for generating random network

What is the best algorithm to generate a random simple (no parallel edges or self-loops) undirected graph with a given number of nodes, where each node has a number of edges that is no less than min and no greater than max?

For example, if min = 2 and max = 5, I would like a graph where approximately 25% of the nodes have 2 edges, approximately 25% of the nodes have 3 edges, approximately 25% of the nodes have 4 edges, and approximately 25% of the nodes have 5 edges.

Upvotes: 9

Views: 1468

Answers (1)

David Eisenstat
David Eisenstat

Reputation: 65447

You could use random_degree_sequence_graph from NetworkX, which uses an algorithm due to Bayati, Kim, and Saberi.

Upvotes: 1

Related Questions