12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #ifndef cmComputeComponentGraph_h
- #define cmComputeComponentGraph_h
- #include "cmConfigure.h"
- #include "cmGraphAdjacencyList.h"
- #include <stack>
- #include <vector>
- class cmComputeComponentGraph
- {
- public:
-
- typedef cmGraphNodeList NodeList;
- typedef cmGraphEdgeList EdgeList;
- typedef cmGraphAdjacencyList Graph;
- cmComputeComponentGraph(Graph const& input);
- ~cmComputeComponentGraph();
-
- Graph const& GetComponentGraph() const { return this->ComponentGraph; }
- EdgeList const& GetComponentGraphEdges(int c) const
- {
- return this->ComponentGraph[c];
- }
-
- std::vector<NodeList> const& GetComponents() const
- {
- return this->Components;
- }
- NodeList const& GetComponent(int c) const { return this->Components[c]; }
-
- std::vector<int> const& GetComponentMap() const
- {
- return this->TarjanComponents;
- }
- private:
- void TransferEdges();
- Graph const& InputGraph;
- Graph ComponentGraph;
-
- struct TarjanEntry
- {
- int Root;
- int VisitIndex;
- };
- std::vector<int> TarjanVisited;
- std::vector<int> TarjanComponents;
- std::vector<TarjanEntry> TarjanEntries;
- std::vector<NodeList> Components;
- std::stack<int> TarjanStack;
- int TarjanWalkId;
- int TarjanIndex;
- void Tarjan();
- void TarjanVisit(int i);
-
- };
- #endif
|