Skip to content

Commit 819a1fd

Browse files
committed
Use T::max_value() instead of the sum of the cost
1 parent 3ce61ef commit 819a1fd

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/mincostflow.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ pub struct MinCostFlowEdge<T> {
1111
pub struct MinCostFlowGraph<T> {
1212
pos: Vec<(usize, usize)>,
1313
g: Vec<Vec<_Edge<T>>>,
14-
cost_sum: T,
1514
}
1615

1716
impl<T> MinCostFlowGraph<T>
@@ -22,7 +21,6 @@ where
2221
Self {
2322
pos: vec![],
2423
g: (0..n).map(|_| vec![]).collect(),
25-
cost_sum: T::zero(),
2624
}
2725
}
2826

@@ -56,7 +54,6 @@ where
5654
assert!(cost >= T::zero());
5755

5856
self.pos.push((from, self.g[from].len()));
59-
self.cost_sum += cost;
6057

6158
let rev = self.g[to].len();
6259
self.g[from].push(_Edge { to, rev, cap, cost });
@@ -131,7 +128,7 @@ where
131128
pe: &mut [usize],
132129
) -> bool {
133130
let n = self.g.len();
134-
let mut dist = vec![self.cost_sum; n];
131+
let mut dist = vec![T::max_value(); n];
135132
let mut vis = vec![false; n];
136133

137134
let mut que = std::collections::BinaryHeap::new();

0 commit comments

Comments
 (0)