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_path_graph#
- directed_path_graph(num_nodes=None, weights=None, bidirectional=False, multigraph=True)#
Generate a directed path 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_nodes
andweights
are set, this will be ignored andweights
will be used.weights (Sequence[Any]) – A sequence of node weights, typically a list. If both
num_nodes
andweights
are set, this will be ignored andweights
will be used.bidirectional (bool) – Adds edges in both directions between two nodes if set to
True
. Default value isFalse
multigraph (bool) – When set to
False
the outputPyDiGraph
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 path graph
- Return type:
- Raises:
IndexError – If neither
num_nodes
orweights
are specified
import rustworkx.generators from rustworkx.visualization import mpl_draw graph = rustworkx.generators.directed_path_graph(10) mpl_draw(graph)