Fix invalid map query in NearestNeighborTsp (#476)
authorAlpar Juttner <alpar@cs.elte.hu>
Wed, 25 Sep 2013 11:15:56 +0200
changeset 129415e233f588da
parent 1292 688a55e4c878
child 1295 f70d8f5a1a5d
child 1298 a78e5b779b69
child 1334 ee96cd1cad8a
Fix invalid map query in NearestNeighborTsp (#476)
lemon/nearest_neighbor_tsp.h
     1.1 --- a/lemon/nearest_neighbor_tsp.h	Sun Aug 11 22:30:44 2013 +0200
     1.2 +++ b/lemon/nearest_neighbor_tsp.h	Wed Sep 25 11:15:56 2013 +0200
     1.3 @@ -115,7 +115,7 @@
     1.4            if (min_edge1 == INVALID) {
     1.5              for (IncEdgeIt e(_gr, n1); e != INVALID; ++e) {
     1.6                if (!used[_gr.runningNode(e)] &&
     1.7 -                  (_cost[e] < _cost[min_edge1] || min_edge1 == INVALID)) {
     1.8 +                  (min_edge1 == INVALID || _cost[e] < _cost[min_edge1])) {
     1.9                  min_edge1 = e;
    1.10                }
    1.11              }
    1.12 @@ -124,7 +124,7 @@
    1.13            if (min_edge2 == INVALID) {
    1.14              for (IncEdgeIt e(_gr, n2); e != INVALID; ++e) {
    1.15                if (!used[_gr.runningNode(e)] &&
    1.16 -                  (_cost[e] < _cost[min_edge2] || min_edge2 == INVALID)) {
    1.17 +                  (min_edge2 == INVALID||_cost[e] < _cost[min_edge2])) {
    1.18                  min_edge2 = e;
    1.19                }
    1.20              }