[−][src]Struct contest_algorithms::graph::flow::FlowGraph
Representation of a network flow problem with (optional) costs.
Fields
graph: Graph
Owned graph, managed by this FlowGraph object.
cap: Vec<i64>
Edge capacities.
cost: Vec<i64>
Edge cost per unit flow.
Implementations
impl FlowGraph
[src]
pub fn new(vmax: usize, emax_hint: usize) -> Self
[src]
Initializes an flow network with vmax vertices and no edges.
pub fn add_edge(&mut self, u: usize, v: usize, cap: i64, rcap: i64, cost: i64)
[src]
Adds an edge with specified directional capacities and cost per unit of flow. If only forward flow is allowed, rcap should be zero.
pub fn dinic(&self, s: usize, t: usize) -> (i64, Vec<i64>)
[src]
Dinic's algorithm to find the maximum flow from s to t where s != t. Generalizes the Hopcroft-Karp maximum bipartite matching algorithm. V^2E in general, min(V^(2/3),sqrt(E))E when all edges are unit capacity, sqrt(V)E when all vertices are unit capacity as in bipartite graphs.
Panics
Panics if the maximum flow is 2^63 or larger.
pub fn min_cut(&self, dist: &[i64]) -> Vec<usize>
[src]
After running maximum flow, use this to recover the dual minimum cut.
pub fn mcf(&self, s: usize, t: usize) -> (i64, i64, Vec<i64>)
[src]
Among all s-t maximum flows, finds one with minimum cost, assuming s != t and no negative-cost cycles.
Panics
Panics if the flow or cost overflow a 64-bit signed integer.
Auto Trait Implementations
impl RefUnwindSafe for FlowGraph
impl Send for FlowGraph
impl Sync for FlowGraph
impl Unpin for FlowGraph
impl UnwindSafe for FlowGraph
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,