I am trying to generate a simple undirected random graph with N number of nodes that has all the degrees of nodes equal. for example, let's say all the node has degree equal to k. I just started using the networkx package and discovered that it offers a variety of random graph generation. Can someone tell me if it is possible to generate a graph where each of the nodes has an equal degree?
1 Answer
Yes, you can use the random_regular_graph() function to generate a graph uniformly at random from all graphs with n nodes and degree k:
import networkx as nx
k = 5
num_nodes = 10
random_graph = nx.random_regular_graph(d=k, n=num_nodes)
1 Comment
Sayeed
thank you so much; it is helpful.