00001 00018 #ifndef StronglyConnectedComponents_H 00019 #define StronglyConnectedComponents_H 00020 00021 #include <set> 00022 00023 #include <OpenAnalysis/Utils/OA_ptr.hpp> 00024 #include <OpenAnalysis/Utils/DGraph/Interface.hpp> 00025 #include <OpenAnalysis/Utils/RIFG.hpp> 00026 00027 //*************************************************************************** 00028 00029 namespace OA { 00030 00031 typedef std::set<OA_ptr<DGraph::Interface::Node> > SCCNodeSet; 00032 00033 00034 //*************************************************************************** 00035 // Class: SCCSet 00036 // 00037 // Description: 00038 // SCCSet is a set of SCCs; each SCC is set of directed graph nodes 00039 // (SCCNodeSet) 00040 // 00041 //*************************************************************************** 00042 00043 class SCCSet : public std::set<OA_ptr<SCCNodeSet> > { 00044 public: 00045 // Given a directed-graph, compute SCC-sets. If available, pass a 00046 // corresponding RIFG, to avoid extra computation. 00047 SCCSet(OA_ptr<DGraph::Interface> graph, OA_ptr<RIFG> rifg = OA_ptr<RIFG>()); 00048 00049 virtual ~SCCSet(); 00050 00051 // NodeToSCC: Given a dgraph node, locate which SCCNodeSet it belongs to. 00052 OA_ptr<SCCNodeSet> NodeToSCC(const OA_ptr<DGraph::Interface::Node> node); 00053 00054 // dump: dump text output useful for debugging 00055 void dump(std::ostream& os); 00056 00057 protected: 00058 typedef std::set<OA_ptr<SCCNodeSet> > self_t; 00059 00060 SCCSet(); 00061 00062 void Create(OA_ptr<DGraph::Interface> graph, OA_ptr<RIFG> rifg); 00063 void Destroy(); 00064 00065 private: 00066 00067 }; 00068 00069 00070 } // end of namespace OA 00071 00072 #endif
1.7.1