cmGraphAdjacencyList.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmGraphAdjacencyList_h
  4. #define cmGraphAdjacencyList_h
  5. #include <cmConfigure.h> // IWYU pragma: keep
  6. #include <vector>
  7. /**
  8. * Graph edge representation. Most use cases just need the
  9. * destination vertex, so we support conversion to/from an int. We
  10. * also store boolean to indicate whether an edge is "strong".
  11. */
  12. class cmGraphEdge
  13. {
  14. public:
  15. cmGraphEdge()
  16. : Dest(0)
  17. , Strong(true)
  18. {
  19. }
  20. cmGraphEdge(int n)
  21. : Dest(n)
  22. , Strong(true)
  23. {
  24. }
  25. cmGraphEdge(int n, bool s)
  26. : Dest(n)
  27. , Strong(s)
  28. {
  29. }
  30. cmGraphEdge(cmGraphEdge const& r)
  31. : Dest(r.Dest)
  32. , Strong(r.Strong)
  33. {
  34. }
  35. operator int() const { return this->Dest; }
  36. bool IsStrong() const { return this->Strong; }
  37. private:
  38. int Dest;
  39. bool Strong;
  40. };
  41. struct cmGraphEdgeList : public std::vector<cmGraphEdge>
  42. {
  43. };
  44. struct cmGraphNodeList : public std::vector<int>
  45. {
  46. };
  47. struct cmGraphAdjacencyList : public std::vector<cmGraphEdgeList>
  48. {
  49. };
  50. #endif