1

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 1

3

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)
Sign up to request clarification or add additional context in comments.

1 Comment

thank you so much; it is helpful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.