ctkDependencyGraph.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef __ctkDependencyGraph_h
  2. #define __ctkDependencyGraph_h
  3. // QT includes
  4. #include <QString>
  5. class ctkDependencyGraph
  6. {
  7. public:
  8. ctkDependencyGraph(int nvertices, int nedges);
  9. ~ctkDependencyGraph();
  10. void printAdditionalInfo();
  11. void printGraph();
  12. /// Get the number of vertices associated with current graph
  13. int numberOfVertices();
  14. /// Get the number of edges associated with current graph
  15. int numberOfEdges();
  16. /// Traverse graph and check for cycle
  17. bool checkForCycle();
  18. /// Return true if there is at least one cycle
  19. bool cycleDetected();
  20. /// If a cycle has been detected, return the origin of the cycle otherwise 0.
  21. int cycleOrigin();
  22. /// If a cycle has been detected, return the end of the cycle otherwise 0.
  23. int cycleEnd();
  24. // The traverse of the tree will print information on standard output
  25. void setVerbose(bool verbose);
  26. /// Insert edge
  27. /// (from, to) indicate a relation between two vertices
  28. /// Note also that vertex id should be >= 1
  29. void insertEdge(int from, int to);
  30. /// Retrieve the path between two vertices
  31. void findPath(int from, int to, QList<int>& path);
  32. /// List of edge to exclude
  33. /// An edge is specified using its extremity
  34. void setEdgeListToExclude(const QList<int>& list);
  35. /// The default implementation check if 'edge' is in the list of edge to exclude
  36. /// See setEdgeListToExclude
  37. virtual bool shouldExcludeEdge(int edge);
  38. /// Called each time an edge is visited
  39. virtual void processEdge(int /*from*/, int /*to*/){}
  40. /// Perform a topological search
  41. /// Return false if the graph contains cycles
  42. /// See cycleDetected, cycleOrigin, cycleEnd
  43. bool topologicalSort(QList<int>& sorted);
  44. private:
  45. class ctkInternal;
  46. ctkInternal* Internal;
  47. };
  48. #endif