pub fn residual_graph(
graph: &Graph,
capacity: &[f64],
flow: &[f64],
) -> IgraphResult<ResidualGraphResult>Expand description
Compute the residual graph given capacity and flow vectors.
For each edge e where capacity[e] - flow[e] > 0, the residual
graph contains the same edge with residual capacity
capacity[e] - flow[e].
§Errors
Returns an error if capacity or flow length differs from the
edge count.
§Examples
use rust_igraph::{Graph, residual_graph};
let mut g = Graph::new(3, true).unwrap();
g.add_edge(0, 1).unwrap(); // edge 0
g.add_edge(1, 2).unwrap(); // edge 1
let capacity = vec![10.0, 5.0];
let flow = vec![7.0, 5.0];
let result = residual_graph(&g, &capacity, &flow).unwrap();
// Edge 0 has residual 3.0, edge 1 is saturated (removed)
assert_eq!(result.graph.vcount(), 3);
assert_eq!(result.graph.ecount(), 1);
assert_eq!(result.capacity, vec![3.0]);