# HG changeset patch
# User Peter Kovacs <kpeter@inf.elte.hu>
# Date 1376944554 -7200
# Node ID b40c2bbb8da5210894426e3c4405b8a6d6d50d22
# Parent fb932bcfd803e4ed14c9d750d924a09eb230aadd
Fix division by zero error in case of empty graph (#474)
diff --git a/lemon/network_simplex.h b/lemon/network_simplex.h
a
|
b
|
|
929 | 929 | for (NodeIt n(_graph); n != INVALID; ++n, ++i) { |
930 | 930 | _node_id[n] = i; |
931 | 931 | } |
932 | | if (_arc_mixing) { |
| 932 | if (_arc_mixing && _node_num > 1) { |
933 | 933 | // Store the arcs in a mixed order |
934 | 934 | const int skip = std::max(_arc_num / _node_num, 3); |
935 | 935 | int i = 0, j = 0; |
diff --git a/test/min_cost_flow_test.cc b/test/min_cost_flow_test.cc
a
|
b
|
|
395 | 395 | mcf3.upperMap(neg2_u); |
396 | 396 | checkMcf(mcf3, mcf3.run(param), neg2_gr, neg2_l, neg2_u, neg2_c, neg2_s, |
397 | 397 | mcf3.OPTIMAL, true, -300, test_str + "-18", GEQ); |
| 398 | |
| 399 | // Tests for empty graph |
| 400 | Digraph gr0; |
| 401 | MCF mcf0(gr0); |
| 402 | mcf0.run(param); |
| 403 | check(mcf0.totalCost() == 0, "Wrong total cost"); |
398 | 404 | } |
399 | 405 | |
400 | 406 | template < typename MCF, typename Param > |