'Generating a random graph with equal node degree?
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?
Solution 1:[1]
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)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | kcsquared |
