pub struct Problem { /* private fields */ }Expand description
A validated min-cost-flow instance.
Construct through Problem::builder. Every invariant the solver relies
on — endpoints in range, lower ≤ upper, supplies summing to zero — is
established here, once, so an invalid instance never exists.
Implementations§
Source§impl Problem
impl Problem
Sourcepub fn builder(node_count: usize) -> ProblemBuilder
pub fn builder(node_count: usize) -> ProblemBuilder
Start building a network with node_count nodes, ids 0..node_count,
every supply zero.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of nodes.
Sourcepub fn supplies(&self) -> &[Flow] ⓘ
pub fn supplies(&self) -> &[Flow] ⓘ
Supply at every node, indexed by node id. Positive is supply, negative is demand; the vector sums to zero.
Sourcepub fn supply(&self, node: usize) -> Option<Flow>
pub fn supply(&self, node: usize) -> Option<Flow>
Supply at node, or None if the id is out of range.
Sourcepub fn canonical(&self) -> (Self, Vec<usize>)
pub fn canonical(&self) -> (Self, Vec<usize>)
A canonical reordering of this instance’s arcs, plus the permutation back to the caller’s order.
Arcs are sorted by (tail, head, cost, lower, upper). Two instances
that differ only in the order their arcs were added produce byte-equal
canonical forms, which is what makes deterministic mode return the same
flow for permuted inputs and not merely the same cost.
The returned vector maps canonical position to original position:
original[perm[i]] is the arc at canonical position i.
Sourcepub fn memory_estimate(&self) -> u64
pub fn memory_estimate(&self) -> u64
Bytes the solver will allocate for this instance, stated up front from the problem size, so a caller can budget memory before committing.
Counts the residual network, the per-node solver state and the
feasibility pre-check. It is an upper bound on steady-state usage, not
a guarantee about transient allocation inside Vec::with_capacity.