CustomDFSVisitors.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef CUSTOMDFSVISITORS_H
  2. #define CUSTOMDFSVISITORS_H
  3. #include <Common/BoostGraphWrapper.h>
  4. #include <boost/graph/depth_first_search.hpp>
  5. /**
  6. * @brief The back_edge_recorder class
  7. *
  8. * Custom DFS Visitor that records back-edges for cycle detection. Inherited from 'default_dfs_visitor' in 'depth_first_search' from Boost.
  9. */
  10. class back_edge_recorder : public default_dfs_visitor
  11. {
  12. public:
  13. /** @name Creators
  14. * The methods under this section are responsible for constructing
  15. * an instance of type back_edge_recorder.
  16. */
  17. //@{
  18. /**
  19. * Construct object of back_edge_recorder
  20. *
  21. * @param vectEdges
  22. * vector of edges as out parameter
  23. */
  24. back_edge_recorder(VectorEdgeDescriptor& vectEdges) : vectBackEdges(&vectEdges) {}
  25. //@}
  26. /** @name Modifiers
  27. * The methods under this section are responsible for modifying
  28. * an instance of type back_edge_recorder.
  29. */
  30. //@{
  31. /**
  32. * It is a visitor function which adds back-edge to the list of visited edges
  33. *
  34. * @param e
  35. * back-edge
  36. *
  37. * @param gGraph
  38. * graph
  39. */
  40. void back_edge(EdgeDescriptor e, SubGraph gGraph)
  41. {
  42. Q_UNUSED(gGraph);
  43. vectBackEdges->push_back(e);
  44. }
  45. //@}
  46. private:
  47. VectorEdgeDescriptor *vectBackEdges; /*!< Vector of edge desctriptors to store back-edges. */
  48. };
  49. #endif // CUSTOMDFSVISITORS_H