cmGraphAdjacencyList.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmGraphAdjacencyList_h
  11. #define cmGraphAdjacencyList_h
  12. #include "cmStandardIncludes.h"
  13. /**
  14. * Graph edge representation. Most use cases just need the
  15. * destination vertex, so we support conversion to/from an int. We
  16. * also store boolean to indicate whether an edge is "strong".
  17. */
  18. class cmGraphEdge
  19. {
  20. public:
  21. cmGraphEdge(): Dest(0), Strong(true) {}
  22. cmGraphEdge(int n): Dest(n), Strong(true) {}
  23. cmGraphEdge(int n, bool s): Dest(n), Strong(s) {}
  24. cmGraphEdge(cmGraphEdge const& r): Dest(r.Dest), Strong(r.Strong) {}
  25. operator int() const { return this->Dest; }
  26. bool IsStrong() const { return this->Strong; }
  27. private:
  28. int Dest;
  29. bool Strong;
  30. };
  31. struct cmGraphEdgeList: public std::vector<cmGraphEdge> {};
  32. struct cmGraphNodeList: public std::vector<int> {};
  33. struct cmGraphAdjacencyList: public std::vector<cmGraphEdgeList> {};
  34. #endif