浏览代码

Simplified if-else statement (TS)

Jan Potocki 5 年前
父节点
当前提交
b2517f51f2
共有 1 个文件被更改,包括 2 次插入9 次删除
  1. 2
    9
      Graph.cpp

+ 2
- 9
Graph.cpp 查看文件

567
                         continue;
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
                         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);

正在加载...
取消
保存