pub struct ProblemBuilder { /* private fields */ }Expand description
Incremental builder for a Problem.
Implementations§
Source§impl ProblemBuilder
impl ProblemBuilder
Sourcepub fn supply(self, node: usize, value: Flow) -> Self
pub fn supply(self, node: usize, value: Flow) -> Self
Set the supply at node. Positive is supply, negative is demand.
Overwrites any previous value for that node. An out-of-range id is
recorded and reported by build, so a builder chain
never needs to be unwrapped mid-way — but it is not accommodated by
growing the network. Silently extending the node space would turn a
mistyped node id into a different, larger problem that solves perfectly
well and answers a question nobody asked.
Sourcepub fn arc(
self,
tail: usize,
head: usize,
lower: Capacity,
upper: Capacity,
cost: Cost,
) -> Self
pub fn arc( self, tail: usize, head: usize, lower: Capacity, upper: Capacity, cost: Cost, ) -> Self
Add an arc tail → head carrying between lower and upper units at
cost per unit.
Sourcepub fn edge(
self,
tail: usize,
head: usize,
capacity: Capacity,
cost: Cost,
) -> Self
pub fn edge( self, tail: usize, head: usize, capacity: Capacity, cost: Cost, ) -> Self
Add an arc with lower bound zero — the common case.
Sourcepub fn build(self) -> Result<Problem, BuildError>
pub fn build(self) -> Result<Problem, BuildError>
Validate and freeze the instance.
§Errors
Returns BuildError if an endpoint is out of range, an arc’s lower
bound exceeds its capacity, the supplies do not sum to zero, or the
network exceeds MAX_NODES / MAX_ARCS.