Note
This is the documentation for the current state of the development branch of rustworkx. The documentation or APIs here can change prior to being released.
rustworkx.generators.directed_complete_graph#
- directed_complete_graph(num_nodes=None, weights=None, multigraph=True)#
Generate a directed complete graph with
nnodes.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
nnodes 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 isn*(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_nodesandweightsare set, this will be ignored andweightswill be used.weights (Sequence[Any]) – A sequence of node weights, typically a list. If both
num_nodesandweightsare set, this will be ignored andweightswill be used.multigraph (bool) – When set to
Falsethe outputPyDiGraphobject 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:
- Raises:
IndexError – If neither
num_nodesorweightsare specified
import rustworkx.generators from rustworkx.visualization import mpl_draw graph = rustworkx.generators.directed_complete_graph(5) mpl_draw(graph)