pub fn widest_path(
graph: &Graph,
from: VertexId,
to: VertexId,
weights: &[f64],
) -> IgraphResult<Option<(Vec<VertexId>, Vec<u32>)>>Expand description
Widest path from from to to: returns the vertex sequence and
the edge sequence along the widest (maximum-bottleneck) path.
Returns Some((vertices, edges)) on success, with
vertices[0] == from, *vertices.last().unwrap() == to, and
edges.len() == vertices.len() - 1. Returns None if to is
unreachable from from. Self-target (from == to) returns
Some((vec![from], vec![])) โ the trivial zero-edge path.
Same semantics as widest_path_widths for weights: negative
finite weights act as small bottlenecks, -f64::INFINITY weights
are ignored, NaN is rejected.
Counterpart of igraph_get_widest_path(_, _, _, from, to, weights, IGRAPH_OUT).
ยงExamples
use rust_igraph::{Graph, widest_path};
// Triangle 0-1-2 with weights 1, 4, 2 โ widest 0โ1 path goes via 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 path = widest_path(&g, 0, 1, &[1.0, 4.0, 2.0]).unwrap().unwrap();
assert_eq!(path.0, vec![0, 2, 1]);
assert_eq!(path.1, vec![1, 2]);