Browse Source

FIX: DGraph: Use topological sort on subgraphs to print dependencies for
graphs with multiple sinks, i.e.

org_commontk_something -> CTKPluginFramework
\
-> CTKCore

Sascha Zelzer 14 years ago
parent
commit
048b58cb64
1 changed files with 18 additions and 20 deletions
  1. 18 20
      Utilities/DGraph/DGraph.cpp

+ 18 - 20
Utilities/DGraph/DGraph.cpp

@@ -256,38 +256,36 @@ int main(int argc, char** argv)
       std::cout << std::endl;
       }
     }
+
+  if (verbose)
+    {
+    QList<int> sources;
+    mygraph.sourceVertices(sources);
+    qDebug() << "Source vertices: " << sources;
+    }
     
   if (outputPath)
     {
     // TODO Make sure label is valid
     QList<int> out;
-    if (mygraph.topologicalSort(out))
+    int labelId = vertexLabelToId[label];
+    if (mygraph.topologicalSort(out, labelId))
       {
-      // Assume all targets depend on the first lib
-      int rootId = out.last();
-      int labelId = vertexLabelToId[label];
-      QList<QList<int>*> paths;
-      mygraph.findPaths(labelId, rootId, paths);
-      for(int i=0; i < paths.size(); i++)
+      for(int i=0; i < out.size(); i++)
         {
-        QList<int>* p = paths[i];
-        Q_ASSERT(p);
-        for(int j=0; j < p->size(); j++)
-          {
-          int id = p->at(j);
+        int id = out.at(i);
+        if (vertexIdToLabel[id].isEmpty())
+          std::cout << "<" << id << ">";
+        else
           std::cout << vertexIdToLabel[id].toStdString();
-          if (j != p->size() - 1)
-            {
-            std::cout << " ";
-            }
-          }
-        if (i != paths.size() - 1)
+
+        if (i != out.size() - 1)
           {
-          std::cout << ";";
+          std::cout << " ";
           }
         }
       }
     }
     
   return EXIT_SUCCESS;
-}
+}