pub fn mcf(&self, s: usize, t: usize) -> (i64, i64) {
        let mut pot = vec![0; self.graph.num_v()];

        // Bellman-Ford deals with negative-cost edges at initialization.
        for _ in 1..self.graph.num_v() {
            for e in 0..self.graph.num_e() {
                if self.cap[e] > 0 {
                    let u = self.graph.endp[e ^ 1];
                    let v = self.graph.endp[e];
                    pot[v] = min(pot[v], pot[u] + self.cost[e]);
                }
            }
        }

        let mut flow = vec![0; self.graph.num_e()];
        let (mut min_cost, mut max_flow) = (0, 0);
        loop {
            let par = self.mcf_search(s, &flow, &mut pot);
            if par[t] == None {
                break;
            }
            let (dc, df) = self.mcf_augment(t, &par, &mut flow);
            min_cost += dc;
            max_flow += df;
        }
        (min_cost, max_flow)
    }
/// Minimum cost maximum flow, assuming no negative-cost cycles.
Minimum cost maximum flow, assuming no negative-cost cycles.
Minimum cost maximum flow assuming no negative - cost cycles .
pub fn mcf(&self, s: usize, t: usize) -> (i64, i64) {
        let mut pot = vec![0; self.graph.num_v()];
        // Bellman-Ford deals with negative-cost edges at initialization.
        for _ in 1..self.graph.num_v() {
            for e in 0..self.graph.num_e() {
                if self.cap[e] > 0 {
                    let u = self.graph.endp[e ^ 1];
                    let v = self.graph.endp[e];
                    pot[v] = min(pot[v], pot[u] + self.cost[e]);
                }
            }
        }
        let mut flow = vec![0; self.graph.num_e()];
        let (mut min_cost, mut max_flow) = (0, 0);
        loop {
            let par = self.mcf_search(s, &flow, &mut pot);
            if par[t] == None {
                break;
            }
            let (dc, df) = self.mcf_augment(t, &par, &mut flow);
            min_cost += dc;
            max_flow += df;
        }
        (min_cost, max_flow)
    }
pub fn mcf ( & self , s : usize , t : usize ) -> ( i64 , i64 ) { let mut pot = vec ! [ 0 self graph num_v ( ) ] ; // Bellman-Ford deals with negative-cost edges at initialization. for _ in 1 .. self . graph . num_v ( ) { for e in 0 .. self . graph . num_e ( ) { if self . cap [ e ] > 0 { let u = self . graph . endp [ e ^ 1 ] ; let v = self . graph . endp [ e ] ; pot [ v ] = min ( pot [ v ] , pot [ u ] + self . cost [ e ] ) ; } } } let mut flow = vec ! [ 0 self graph num_e ( ) ] ; let ( mut min_cost , mut max_flow ) = ( 0 , 0 ) ; loop { let par = self . mcf_search ( s , & flow , & mut pot ) ; if par [ t ] == None { break ; } let ( dc , df ) = self . mcf_augment ( t , & par , & mut flow ) ; min_cost += dc ; max_flow += df ; } ( min_cost , max_flow ) }
Minimum cost maximum flow, assuming no negative-cost cycles.
Minimum cost maximum flow assuming no negative - cost cycles .
&self
s
usize
t
usize
&self
s
usize
t
usize