Преглед на файлове

ENH: Dependency Graph: find a path from between two vertices in graphs
with multiple sinks and cycles, for example find a path from 1 to 4:

-> 3
/
1 -> 2 -> 4

Sascha Zelzer преди 15 години
родител
ревизия
59dfa909b0
променени са 1 файла, в които са добавени 6 реда и са изтрити 11 реда
  1. 6 11
      Libs/Core/ctkDependencyGraph.cpp

+ 6 - 11
Libs/Core/ctkDependencyGraph.cpp

@@ -483,19 +483,14 @@ void ctkDependencyGraph::findPaths(int from, int to, QList<QList<int>* >& paths)
 //----------------------------------------------------------------------------
 void ctkDependencyGraph::findPath(int from, int to, QList<int>& path)
 {
-  int child = from;
-  int parent = this->Internal->edge(child, 0);
-  path << child; 
-  while (parent > 0)
+  QList<QList<int>* > paths;
+  this->findPaths(from, to, paths);
+  if (!paths.empty())
     {
-    path << parent;
-    if (parent == to)
-      {
-      break;
-      }
-    child = parent;
-    parent = this->Internal->edge(child, 0);
+    path << *(paths.first());
     }
+
+  qDeleteAll(paths);
 }
 
 //----------------------------------------------------------------------------