Skip to main content

max_flow

Function max_flow 

Source
pub fn max_flow(
    n: usize,
    source: usize,
    sink: usize,
    edges: &[(usize, usize, i64)],
) -> MaxFlowResult
Expand description

Compute the maximum flow in a network using the Tide algorithm.

§Arguments

  • n - Number of vertices (0-indexed)
  • source - Source vertex
  • sink - Sink vertex
  • edges - List of (from, to, capacity) tuples

§Returns

A MaxFlowResult containing the max flow value, step count, and per-edge flows.

§Example

use tide_maxflow::max_flow;
let result = max_flow(4, 0, 3, &[(0, 1, 10), (0, 2, 10), (1, 3, 10), (2, 3, 10)]);
assert_eq!(result.flow, 20);