Переглянути джерело

Simplified if-else statement (TS)

Jan Potocki 5 роки тому
джерело
коміт
b2517f51f2
1 змінених файлів з 2 додано та 9 видалено
  1. 2
    9
      Graph.cpp

+ 2
- 9
Graph.cpp Переглянути файл

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

Завантаження…
Відмінити
Зберегти