GraphCycleHandler.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #ifndef GRAPHCYCLEHANDLER_H
  2. #define GRAPHCYCLEHANDLER_H
  3. #include <GraphLayoutLibrary_global.h>
  4. #include <Common/BoostGraphWrapper.h>
  5. #include <boost/graph/depth_first_search.hpp>
  6. #include <Common/CustomDFSVisitors.h>
  7. #include <QDebug>
  8. #include <QQueue>
  9. /**
  10. * @brief The GraphCycleHandler class
  11. *
  12. * The class provides helpers to manage edge cycles in graph.
  13. */
  14. class GRAPHLAYOUTLIBRARYSHARED_EXPORT GraphCycleHandler
  15. {
  16. private:
  17. BoostGraphWrapper m_BoostGraphWrapper; /*!< Local instance of BoostGraphWrapper */
  18. public:
  19. /** @name Creators
  20. * The methods under this section are responsible for constructing or
  21. * destructing an instance of type GraphCycleHandler.
  22. */
  23. //@{
  24. /**
  25. Constructs new object of type GraphCycleHandler.
  26. @pre none
  27. @param none
  28. @return none
  29. @throw none
  30. */
  31. GraphCycleHandler();
  32. //@}
  33. /** @name Modifiers
  34. * The methods under this section are responsible for modifying
  35. * an instance of GraphCycleHandler.
  36. */
  37. //@{
  38. /** This function reverses the edge from given graph marks reverse edge property to true which might be helpful for the algorithm to know which edges are reversed
  39. @pre none
  40. @param gGraph
  41. reference to graph
  42. @param vectBackEdges
  43. reference to vector of back edges which are to be reversed
  44. @return none
  45. @throw boost graph exception
  46. */
  47. void reverseEdges(SubGraph& gGraph, VectorEdgeDescriptor& vectBackEdges);
  48. //@}
  49. /** @name Queries
  50. * The methods under this section are responsible for accessing
  51. * an instance of type GraphCycleHandler.
  52. */
  53. //@{
  54. /** detectBackEdges function detects edge cycles using boost DFS and gives the list of back edges
  55. @pre
  56. -# gGraph != NULL
  57. @param gGraph
  58. reference to graph
  59. @param vectBackEdges
  60. reference to empty vector of edges
  61. @return none
  62. @throw boost graph exception
  63. */
  64. void detectBackEdges(SubGraph& gGraph , VectorEdgeDescriptor& vectBackEdges);
  65. /** This function checks if an edge between the two vertices creates a cycle or not. It assumes that there is no cylce present in the graph.
  66. @pre
  67. -# gGraph != NULL
  68. -# gGraph is acyclic
  69. @param gGraph
  70. reference to graph
  71. @param vectBackEdges
  72. reference to vector of back edges which are to be reversed
  73. @return none
  74. @throw none
  75. */
  76. bool doesEdgeCreateCycle(VertexDescriptor vSource , VertexDescriptor vTarget , SubGraph& gGraph);
  77. //@}
  78. };
  79. #endif // GRAPHCYCLEHANDLER_H