pub fn widest_paths(
graph: &Graph,
from: VertexId,
weights: &[f64],
) -> IgraphResult<WidestPaths>Expand description
Single-source widest-paths sidecar: widths plus the parent-pointer SPT. Convenient when you want all of widths, parent vertices, and inbound edge ids in one call without re-running the SPT.
Behaves like widest_path_widths for weight semantics: NaN
rejected, -f64::INFINITY edges ignored, negative finite weights
act as small bottlenecks.
Counterpart of igraph_get_widest_paths(_, NULL, NULL, source, vss_all(), weights, IGRAPH_OUT, parents, inbound_edges) from
references/igraph/src/paths/widest_paths.c:102.
§Examples
use rust_igraph::{Graph, widest_paths};
// Triangle 0-1-2 weights (1, 4, 2). Widest 0→1 routes via vertex 2.
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap(); // edge 0, width 1
g.add_edge(0, 2).unwrap(); // edge 1, width 4
g.add_edge(1, 2).unwrap(); // edge 2, width 2
let sp = widest_paths(&g, 0, &[1.0, 4.0, 2.0]).unwrap();
// Source itself
assert_eq!(sp.widths[0], Some(f64::INFINITY));
assert_eq!(sp.parents[0], None);
assert_eq!(sp.inbound_edges[0], None);
// Vertex 2 reached directly via edge 1 (widest direct edge)
assert_eq!(sp.parents[2], Some(0));
assert_eq!(sp.inbound_edges[2], Some(1));
// Vertex 1 reached via 2 (bottleneck min(4, 2) = 2 beats direct edge 0 with width 1)
assert_eq!(sp.parents[1], Some(2));
assert_eq!(sp.inbound_edges[1], Some(2));