Open
Graph Drawing
Framework

 v.2007.11
 

extended_graph_alg.h

Go to the documentation of this file.
00001 /*
00002  * $Revision: 1.4 $
00003  * 
00004  * last checkin:
00005  *   $Author: gutwenger $ 
00006  *   $Date: 2007-11-08 16:10:37 +0100 (Do, 08 Nov 2007) $ 
00007  ***************************************************************/
00008  
00050 #ifdef _MSC_VER
00051 #pragma once
00052 #endif
00053 
00054 #ifndef OGDF_EXTENDED_GRAPH_ALG_H
00055 #define OGDF_EXTENDED_GRAPH_ALG_H
00056 
00057 
00058 #include <ogdf/cluster/ClusterGraph.h>
00059 
00060 namespace ogdf {
00061 
00062 
00063 //---------------------------------------------------------
00064 // Methods for induced subgraphs
00065 //---------------------------------------------------------
00066 
00068 template<class LISTITERATOR>
00069 void inducedSubGraph(const Graph &G, LISTITERATOR start, Graph &subGraph)
00070 {
00071     NodeArray<node> nodeTableOrig2New;
00072     inducedSubGraph(G,start,subGraph,nodeTableOrig2New);
00073 }
00074 
00076 template<class LISTITERATOR>
00077 void inducedSubGraph(const Graph &G,
00078                      LISTITERATOR start,
00079                      Graph &subGraph,
00080                      NodeArray<node> &nodeTableOrig2New)
00081 {
00082     subGraph.clear();
00083     nodeTableOrig2New.init(G,0);
00084 
00085     EdgeArray<bool> mark(G,false);
00086 
00087     LISTITERATOR its;
00088     for (its = start; its.valid(); its++)
00089     {
00090         node w = (*its);
00091         OGDF_ASSERT(w != 0 && w->graphOf() == &G);
00092         nodeTableOrig2New[w] = subGraph.newNode();
00093 
00094         adjEntry adj = w->firstAdj();
00095         forall_adj(adj,w)
00096         {
00097             edge e = adj->theEdge();
00098             if (nodeTableOrig2New[e->source()] && nodeTableOrig2New[e->target()] && !mark[e])
00099             {
00100                 subGraph.newEdge(nodeTableOrig2New[e->source()],nodeTableOrig2New[e->target()]);
00101                 mark[e] = true;
00102             }
00103         }
00104     }
00105 }
00106                      
00107 
00109 template<class LISTITERATOR>
00110 void inducedSubGraph(const Graph &G,
00111                      LISTITERATOR start,
00112                      Graph &subGraph,
00113                      NodeArray<node> &nodeTableOrig2New,
00114                      EdgeArray<edge> &edgeTableOrig2New)
00115 {
00116     subGraph.clear();
00117     nodeTableOrig2New.init(G,0);
00118     edgeTableOrig2New.init(G,0);
00119 
00120     EdgeArray<bool> mark(G,false);
00121 
00122     LISTITERATOR its;
00123     for (its = start; its.valid(); its++)
00124     {
00125         node w = (*its);
00126         OGDF_ASSERT(w != 0 && w->graphOf() == &G);
00127         nodeTableOrig2New[w] = subGraph.newNode();
00128 
00129         adjEntry adj = w->firstAdj();
00130         forall_adj(adj,w)
00131         {
00132             edge e = adj->theEdge();
00133             if (nodeTableOrig2New[e->source()] && 
00134                 nodeTableOrig2New[e->target()] && 
00135                 !mark[e])
00136             {
00137                 edgeTableOrig2New[e] = 
00138                     subGraph.newEdge(
00139                         nodeTableOrig2New[e->source()],
00140                         nodeTableOrig2New[e->target()]);
00141                 mark[e] = true;
00142             }
00143         }
00144     }
00145 }
00146 
00147 
00148 template<class NODELISTITERATOR,class EDGELIST>
00149 void inducedSubgraph(Graph &G,NODELISTITERATOR &it,EDGELIST &E)
00150 {
00151     NODELISTITERATOR itBegin = it;
00152     NodeArray<bool>  mark(G,false);
00153 
00154     for (;it.valid();it++)
00155         mark[(*it)] = true;
00156     it = itBegin;
00157     for (;it.valid();it++)
00158     {
00159         node v = (*it);
00160         adjEntry adj;
00161         forall_adj(adj,v)
00162         {
00163             edge e = adj->theEdge();
00164             if (mark[e->source()] && mark[e->target()])
00165                 E.pushBack(e);
00166         }
00167     }
00168 }
00169 
00170 
00171 //---------------------------------------------------------
00172 // Methods for clustered graphs
00173 //---------------------------------------------------------
00174 
00175 
00176 // true <=> C is C-connected
00177 bool isCConnected(const ClusterGraph &C);
00178 
00179 //connect clusters to achieve c-connectivity (probably loosing planarity)
00180 //GG is underlying graph of C, returns inserted edges in addededges
00181 //simple: only connect underlying cluster subgraph without crossing check
00182 void makeCConnected(ClusterGraph& C, Graph& GG, List<edge>& addedEdges,
00183                     bool simple = true);
00184 
00185 
00186 
00187 
00188 //---------------------------------------------------------
00189 // Methods for st-numbering
00190 //---------------------------------------------------------
00191 
00192 
00193 // Computes an st-Numbering.
00194 // Precondition: G must be biconnected and simple.
00195 // Exception: the Graph is allowed to have isolated nodes.
00196 // The st-numbers are stored in NodeArray. Return value is 
00197 // the number t. It is 0, if the computation was unsuccessful.
00198 // The nodes s and t may be specified. In this case 
00199 // s and t have to be adjacent.
00200 // If s and t are set 0 and parameter randomized is set to true,
00201 // the st edge is chosen to be a random edge in G.
00202 int stNumber(const Graph &G,
00203     NodeArray<int> &numbering,
00204     node s = 0,
00205     node t = 0,
00206     bool randomized = false);
00207 
00208 // Tests, whether a numbering is an st-numbering
00209 // Precondition: G must be biconnected and simple.
00210 // Exception: the Graph is allowed to have isolated nodes.
00211 bool testSTnumber(const Graph &G, NodeArray<int> &st_no,int max);
00212 
00213 } // end namespace ogdf
00214 
00215 
00216 #endif


© 1999-2007 by oreas GmbH, © 2005-2007 by University Dortmund and University Cologne.

Generated on Thu Nov 22 19:40:01 2007 by doxygen 1.5.4.