COIN-OR::LEMON - Graph Library

Ticket #476: 39d27d0b7939.patch

File 39d27d0b7939.patch, 1.2 KB (added by Alpar Juttner, 11 years ago)
  • lemon/nearest_neighbor_tsp.h

    # HG changeset patch
    # User Alpar Juttner <alpar@cs.elte.hu>
    # Date 1380100556 -7200
    #      Wed Sep 25 11:15:56 2013 +0200
    # Node ID 39d27d0b7939d1816629231394350b5023240464
    # Parent  c08d0f04c1176379ba7e476d321ccc4992840ab9
    Fix invalid map query in NearestNeighborTsp (#476)
    
    diff --git a/lemon/nearest_neighbor_tsp.h b/lemon/nearest_neighbor_tsp.h
    a b  
    115115          if (min_edge1 == INVALID) {
    116116            for (IncEdgeIt e(_gr, n1); e != INVALID; ++e) {
    117117              if (!used[_gr.runningNode(e)] &&
    118                   (_cost[e] < _cost[min_edge1] || min_edge1 == INVALID)) {
     118                  (min_edge1 == INVALID || _cost[e] < _cost[min_edge1])) {
    119119                min_edge1 = e;
    120120              }
    121121            }
     
    124124          if (min_edge2 == INVALID) {
    125125            for (IncEdgeIt e(_gr, n2); e != INVALID; ++e) {
    126126              if (!used[_gr.runningNode(e)] &&
    127                   (_cost[e] < _cost[min_edge2] || min_edge2 == INVALID)) {
     127                  (min_edge2 == INVALID||_cost[e] < _cost[min_edge2])) {
    128128                min_edge2 = e;
    129129              }
    130130            }