lemon/nearest_neighbor_tsp.h
changeset 1140 f8ec64f78b5f
parent 1092 dceba191c00d
equal deleted inserted replaced
6:0e2d8246967e 7:337a965709be
   113         min_edge1 = INVALID;
   113         min_edge1 = INVALID;
   114         while (int(path_dq.size()) != _gr.nodeNum()) {
   114         while (int(path_dq.size()) != _gr.nodeNum()) {
   115           if (min_edge1 == INVALID) {
   115           if (min_edge1 == INVALID) {
   116             for (IncEdgeIt e(_gr, n1); e != INVALID; ++e) {
   116             for (IncEdgeIt e(_gr, n1); e != INVALID; ++e) {
   117               if (!used[_gr.runningNode(e)] &&
   117               if (!used[_gr.runningNode(e)] &&
   118                   (_cost[e] < _cost[min_edge1] || min_edge1 == INVALID)) {
   118                   (min_edge1 == INVALID || _cost[e] < _cost[min_edge1])) {
   119                 min_edge1 = e;
   119                 min_edge1 = e;
   120               }
   120               }
   121             }
   121             }
   122           }
   122           }
   123 
   123 
   124           if (min_edge2 == INVALID) {
   124           if (min_edge2 == INVALID) {
   125             for (IncEdgeIt e(_gr, n2); e != INVALID; ++e) {
   125             for (IncEdgeIt e(_gr, n2); e != INVALID; ++e) {
   126               if (!used[_gr.runningNode(e)] &&
   126               if (!used[_gr.runningNode(e)] &&
   127                   (_cost[e] < _cost[min_edge2] || min_edge2 == INVALID)) {
   127                   (min_edge2 == INVALID||_cost[e] < _cost[min_edge2])) {
   128                 min_edge2 = e;
   128                 min_edge2 = e;
   129               }
   129               }
   130             }
   130             }
   131           }
   131           }
   132 
   132