Browse Source

Simplified if-else statement (TS)

Jan Potocki 5 years ago
parent
commit
b2517f51f2
1 changed files with 2 additions and 9 deletions
  1. 2
    9
      Graph.cpp

+ 2
- 9
Graph.cpp View File

567
                         continue;
567
                         continue;
568
 
568
 
569
 
569
 
570
-                    if(nextRouteLength == -1)
570
+                    if(nextRouteLength == -1 || nextRouteLength > neighbourRouteLength)
571
-                    {
572
-                        nextRouteLength = neighbourRouteLength;
573
-                        nextRoute = neighbourRoute;
574
-                        nextTabu.at(1) = i;
575
-                        nextTabu.at(2) = j;
576
-                    }
577
-                    else if(nextRouteLength > neighbourRouteLength)
578
                     {
571
                     {
579
                         nextRouteLength = neighbourRouteLength;
572
                         nextRouteLength = neighbourRouteLength;
580
                         nextRoute = neighbourRoute;
573
                         nextRoute = neighbourRoute;
692
                 {
685
                 {
693
                     currentRoute = Graph::travellingSalesmanHybrid(graph);
686
                     currentRoute = Graph::travellingSalesmanHybrid(graph);
694
                     currentRouteLength = 0;
687
                     currentRouteLength = 0;
695
-                    
688
+
696
                     for(int i = 1; i < currentRoute.size(); i++)
689
                     for(int i = 1; i < currentRoute.size(); i++)
697
                         currentRouteLength += graph.getWeight(currentRoute.at(i - 1), currentRoute.at(i));
690
                         currentRouteLength += graph.getWeight(currentRoute.at(i - 1), currentRoute.at(i));
698
                 } while(currentRouteLength > criticalLength);
691
                 } while(currentRouteLength > criticalLength);

Loading…
Cancel
Save