[Lemon-commits] Alpar Juttner: Fix invalid map query in NearestN...

Lemon HG hg at lemon.cs.elte.hu
Thu Oct 10 17:27:04 CEST 2013


details:   http://lemon.cs.elte.hu/hg/lemon/rev/15e233f588da
changeset: 1294:15e233f588da
user:      Alpar Juttner <alpar [at] cs.elte.hu>
date:      Wed Sep 25 11:15:56 2013 +0200
description:
	Fix invalid map query in NearestNeighborTsp (#476)

diffstat:

 lemon/nearest_neighbor_tsp.h |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (21 lines):

diff --git a/lemon/nearest_neighbor_tsp.h b/lemon/nearest_neighbor_tsp.h
--- a/lemon/nearest_neighbor_tsp.h
+++ b/lemon/nearest_neighbor_tsp.h
@@ -115,7 +115,7 @@
           if (min_edge1 == INVALID) {
             for (IncEdgeIt e(_gr, n1); e != INVALID; ++e) {
               if (!used[_gr.runningNode(e)] &&
-                  (_cost[e] < _cost[min_edge1] || min_edge1 == INVALID)) {
+                  (min_edge1 == INVALID || _cost[e] < _cost[min_edge1])) {
                 min_edge1 = e;
               }
             }
@@ -124,7 +124,7 @@
           if (min_edge2 == INVALID) {
             for (IncEdgeIt e(_gr, n2); e != INVALID; ++e) {
               if (!used[_gr.runningNode(e)] &&
-                  (_cost[e] < _cost[min_edge2] || min_edge2 == INVALID)) {
+                  (min_edge2 == INVALID||_cost[e] < _cost[min_edge2])) {
                 min_edge2 = e;
               }
             }


More information about the Lemon-commits mailing list