COIN-OR::LEMON - Graph Library

Ticket #474: 474-b40c2bbb8da5.patch

File 474-b40c2bbb8da5.patch, 1.2 KB (added by Peter Kovacs, 6 years ago)
  • lemon/network_simplex.h

    # 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  
    929929      for (NodeIt n(_graph); n != INVALID; ++n, ++i) {
    930930        _node_id[n] = i;
    931931      }
    932       if (_arc_mixing) {
     932      if (_arc_mixing && _node_num > 1) {
    933933        // Store the arcs in a mixed order
    934934        const int skip = std::max(_arc_num / _node_num, 3);
    935935        int i = 0, j = 0;
  • test/min_cost_flow_test.cc

    diff --git a/test/min_cost_flow_test.cc b/test/min_cost_flow_test.cc
    a b  
    395395  mcf3.upperMap(neg2_u);
    396396  checkMcf(mcf3, mcf3.run(param), neg2_gr, neg2_l, neg2_u, neg2_c, neg2_s,
    397397           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"); 
    398404}
    399405
    400406template < typename MCF, typename Param >