Open
Graph Drawing
Framework

 v.2012.05
 

StaticSPQRTree.h
Go to the documentation of this file.
00001 /*
00002  * $Revision: 2299 $
00003  * 
00004  * last checkin:
00005  *   $Author: gutwenger $ 
00006  *   $Date: 2012-05-07 15:57:08 +0200 (Mon, 07 May 2012) $ 
00007  ***************************************************************/
00008  
00043 #ifdef _MSC_VER
00044 #pragma once
00045 #endif
00046 
00047 
00048 #ifndef OGDF_STATIC_SPQR_TREE_H
00049 #define OGDF_STATIC_SPQR_TREE_H
00050 
00051 
00052 #include <ogdf/decomposition/SPQRTree.h>
00053 #include <ogdf/decomposition/StaticSkeleton.h>
00054 
00055 
00056 namespace ogdf {
00057 
00058     class TricComp;
00059 
00060 //---------------------------------------------------------
00061 // StaticSPQRTree
00062 // SPQR-tree data structure (static environment)
00063 //---------------------------------------------------------
00064 
00097 class OGDF_EXPORT StaticSPQRTree : public virtual SPQRTree
00098 {
00099 public:
00100 
00101     friend class OGDF_EXPORT StaticSkeleton;
00102 
00103 
00104     // constructors
00105 
00111     StaticSPQRTree(const Graph &G) : m_skOf(G), m_copyOf(G) { m_pGraph = &G; init(G.firstEdge()); }
00112 
00118     StaticSPQRTree(const Graph &G, edge e) : m_skOf(G), m_copyOf(G) { m_pGraph = &G; init(e); }
00119 
00125     StaticSPQRTree(const Graph &G, TricComp &tricComp) : m_skOf(G), m_copyOf(G) { m_pGraph = &G; init(G.firstEdge(),tricComp); }
00126 
00127 
00128     // destructor
00129 
00130     ~StaticSPQRTree();
00131 
00132 
00133     //
00134     // a) Access operations
00135     //
00136 
00138     const Graph &originalGraph() const { return *m_pGraph; }
00139 
00141     const Graph &tree() const { return m_tree; }
00142 
00144     edge rootEdge() const { return m_rootEdge; }
00145 
00147     node rootNode() const { return m_rootNode; }
00148 
00150     int numberOfSNodes() const { return m_numS; }
00151 
00153     int numberOfPNodes() const { return m_numP; }
00154 
00156     int numberOfRNodes() const { return m_numR; }
00157 
00162     NodeType typeOf(node v) const { return m_type[v]; }
00163 
00165     List<node> nodesOfType(NodeType t) const;
00166 
00171     Skeleton &skeleton(node v) const { return *m_sk[v]; }
00172 
00177     edge skeletonEdgeSrc(edge e) const { return m_skEdgeSrc[e]; }
00178 
00183     edge skeletonEdgeTgt(edge e) const { return m_skEdgeTgt[e]; }
00184 
00189     const Skeleton &skeletonOfReal(edge e) const { return *m_skOf[e]; }
00190 
00195     edge copyOfReal(edge e) const { return m_copyOf[e]; }
00196 
00197 
00198     //
00199     // b) Update operations
00200     //
00201 
00206     node rootTreeAt(edge e);
00207 
00212     node rootTreeAt(node v);
00213 
00214 
00215 protected:
00216 
00218     void init(edge e);
00219 
00221     void init(edge eRef, TricComp &tricComp);
00222 
00224     void rootRec(node v, edge ef);
00225 
00230     void cpRec(node v, PertinentGraph &Gp) const
00231     {
00232         edge e;
00233         const Skeleton &S = skeleton(v);
00234 
00235         forall_edges(e,S.getGraph()) {
00236             edge eOrig = S.realEdge(e);
00237             if (eOrig != 0) cpAddEdge(eOrig,Gp);
00238         }
00239 
00240         forall_adj_edges(e,v) {
00241             node w = e->target();
00242             if (w != v) cpRec(w,Gp);
00243         }
00244     }
00245 
00246 
00247     const Graph *m_pGraph;  
00248     Graph        m_tree;    
00249 
00250     edge m_rootEdge;  
00251     node m_rootNode;  
00252 
00253     int m_numS;  
00254     int m_numP;  
00255     int m_numR;  
00256 
00257     NodeArray<NodeType> m_type;  
00258 
00259     NodeArray<StaticSkeleton *> m_sk;         
00260     EdgeArray<edge>             m_skEdgeSrc;  
00261     EdgeArray<edge>             m_skEdgeTgt;  
00262 
00263     EdgeArray<StaticSkeleton *> m_skOf;    
00264     EdgeArray<edge>             m_copyOf;  
00265 
00266 }; // class StaticSPQRTree
00267 
00268 
00269 } // end namespace ogdf
00270 
00271 
00272 #endif