rustworkx.random_regular_graph

random_regular_graph(num_nodes, degree, /, seed=None)

Return a random undirected \(d\)-regular graph on \(n\) nodes.

A regular graph is a graph where each node has the same number of neighbors, i.e., the same degree \(d\). The product \(n d\) must be even. The resulting graph has no self-loops or parallel edges.

This implementation is based on the networkx function random_regular_graph [1].

Parameters:
  • num_nodes (int) – The number of nodes to create in the graph

  • degree (int) – The degree that every node will have

  • seed (int) – An optional seed to use for the random number generator

Returns:

A PyGraph object

Return type:

PyGraph