Skip to main content

random_walks_from

Function random_walks_from 

Source
pub fn random_walks_from(
    graph: &Graph,
    starts: &[VertexId],
    weights: Option<&[f64]>,
    mode: DijkstraMode,
    walks_per_vertex: u32,
    walk_length: u32,
    seed: u64,
) -> IgraphResult<Vec<Vec<VertexId>>>
Expand description

Generate random walks from a specific set of starting vertices.

Unlike random_walks which walks from every vertex, this function generates walks only from the provided starts list.

ยงExamples

use rust_igraph::{Graph, random_walks_from, DijkstraMode};

let g = Graph::from_edges(
    &[(0,1),(1,2),(2,3),(3,0)], false, Some(4)
).unwrap();
let corpus = random_walks_from(
    &g, &[0, 2], None, DijkstraMode::Out, 3, 5, 42
).unwrap();
assert_eq!(corpus.len(), 6); // 2 starts * 3 walks
for walk in &corpus {
    assert!(walk[0] == 0 || walk[0] == 2);
}