rustworkx.generators.directed_complete_graph#

directed_complete_graph(num_nodes=None, weights=None, multigraph=True)#

Generate a directed complete graph with n nodes.

A directed complete graph is a directed graph in which each pair of distinct vertices is connected by a unique pair of directed edges. The directed complete graph on n nodes is the graph with the set of nodes {0, 1, ..., n-1} and the set of edges {(i, j) : 0 <= i < n, 0 <= j < n}. The number of edges in the directed complete graph is n*(n-1).

Parameters:
  • num_nodes (int) – The number of nodes to generate the graph with. Node weights will be None if this is specified. If both num_nodes and weights are set this will be ignored and weights will be used.

  • weights (list) – A list of node weights. If both num_nodes and weights are set this will be ignored and weights will be used.

  • multigraph (bool) – When set to False the output PyDiGraph object will not be not be a multigraph and won’t allow parallel edges to be added. Instead calls which would create a parallel edge will update the existing edge.

Returns:

The generated directed complete graph

Return type:

PyDiGraph

Raises:

IndexError – If neither num_nodes or weights are specified

import rustworkx.generators
from rustworkx.visualization import mpl_draw

graph = rustworkx.generators.directed_complete_graph(5)
mpl_draw(graph)
../_images/rustworkx.generators.directed_complete_graph_0_0.png