Skip to main content

random_spanning_tree

Function random_spanning_tree 

Source
pub fn random_spanning_tree<N, E, Ix, R>(
    graph: &Graph<N, E, Ix>,
    rng: &mut R,
) -> Result<Graph<N, E, Ix>>
where N: Node + Debug, E: EdgeWeight + Clone, Ix: IndexType, R: Rng,
Expand description

Generates a random spanning tree from an existing graph

Uses Kruskal’s algorithm with randomized edge selection to produce a random spanning tree of the input graph.

§Arguments

  • graph - The input graph to extract a spanning tree from
  • rng - Random number generator

§Returns

  • Result<Graph<N, E>> - A spanning tree of the input graph