Skip to main content

random_spanning_tree_directed

Function random_spanning_tree_directed 

Source
pub fn random_spanning_tree_directed(
    digraph: &DiGraph,
    root: &str,
    seed: u64,
) -> Option<DiGraph>
Expand description

Generate a random spanning tree for a directed graph.

Returns a random spanning arborescence rooted at the specified node. Uses random walk with loop erasure (Wilson’s algorithm adapted for digraphs).

Returns None if the graph is empty, the root doesn’t exist, or the root cannot reach all other nodes.