rustworkx.generators.directed_cycle_graph#
- directed_cycle_graph(num_nodes=None, weights=None, bidirectional=False, multigraph=True, /)#
Generate a directed cycle graph
- 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 (list) – A list of node weights, the first element in the list will be the center node of the cycle graph. If both
num_nodesandweightsare set this will be ignored andweightswill be used.bidirectional (bool) – Adds edges in both directions between two nodes if set to
True. Default value isFalsemultigraph (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 cycle graph
- Return type:
- Raises:
IndexError – If neither
num_nodesorweightsare specified
import rustworkx.generators from rustworkx.visualization import mpl_draw graph = rustworkx.generators.directed_cycle_graph(5) mpl_draw(graph)