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.generate_random_path¶
- generate_random_path(graph, /, source, length, seed=None)[source]¶
Return a random path (or random walk) on a graph.
The next node to visit is selected uniformly at random from the neighbors (or outgoing neighbors for directed graphs). If a node of the path has no neighbor (or no outgoing neighbor for directed graphs), the path will stop early.
- Parameters:
- Returns:
List of visited nodes including the initial node source.
- Return type:
list[int]
- Raises:
IndexError – when the graph doesn’t contain the source node.