00001
00002
00003
00004
00005
00006
00007
00008
00042 #ifdef _MSC_VER
00043 #pragma once
00044 #endif
00045
00046 #ifndef OGDF_MM_VARIABLE_EMBEDDING_INSERTER_H
00047 #define OGDF_MM_VARIABLE_EMBEDDING_INSERTER_H
00048
00049
00050
00051 #include <ogdf/module/MMEdgeInsertionModule.h>
00052 #include <ogdf/basic/CombinatorialEmbedding.h>
00053 #include <ogdf/basic/FaceArray.h>
00054 #include <ogdf/basic/tuples.h>
00055
00056
00057
00058 namespace ogdf {
00059
00060 class OGDF_EXPORT NodeSet;
00061 class OGDF_EXPORT StaticPlanarSPQRTree;
00062
00063
00065 class OGDF_EXPORT MMVariableEmbeddingInserter : public MMEdgeInsertionModule
00066 {
00067 public:
00069 MMVariableEmbeddingInserter();
00070
00071
00072 virtual ~MMVariableEmbeddingInserter() { }
00073
00074
00076 void removeReinsert(RemoveReinsertType rrOption) {
00077 m_rrOption = rrOption;
00078 }
00079
00081 RemoveReinsertType removeReinsert() const {
00082 return m_rrOption;
00083 }
00084
00085
00087
00092 void percentMostCrossed(double percent) {
00093 m_percentMostCrossed = percent;
00094 }
00095
00097 double percentMostCrossed() const {
00098 return m_percentMostCrossed;
00099 }
00100
00101
00102 private:
00103 class Block;
00104 class ExpandedSkeleton;
00105
00106 typedef PlanRepExpansion::Crossing Crossing;
00107
00108 struct AnchorNodeInfo {
00109 AnchorNodeInfo() { m_adj_1 = m_adj_2 = 0; }
00110 AnchorNodeInfo(adjEntry adj) {
00111 m_adj_1 = adj;
00112 m_adj_2 = 0;
00113 }
00114 AnchorNodeInfo(adjEntry adj_1, adjEntry adj_2) {
00115 m_adj_1 = adj_1;
00116 m_adj_2 = adj_2;
00117 }
00118
00119 adjEntry m_adj_1;
00120 adjEntry m_adj_2;
00121 };
00122
00123 enum PathType { pathToEdge = 0, pathToSource = 1, pathToTarget = 2 };
00124
00125 struct Paths {
00126 Paths() :
00127 m_addPartLeft(3), m_addPartRight(3),
00128 m_paths(3),
00129 m_src(0,2,0), m_tgt(0,2,0),
00130 m_pred(0,2,0)
00131 { }
00132
00133 Array<SList<adjEntry> > m_addPartLeft;
00134 Array<SList<adjEntry> > m_addPartRight;
00135 Array<List<Crossing> > m_paths;
00136 Array<AnchorNodeInfo> m_src;
00137 Array<AnchorNodeInfo> m_tgt;
00138 Array<int> m_pred;
00139 };
00140
00150 ReturnType doCall(
00151 PlanRepExpansion &PG,
00152 const List<edge> &origEdges,
00153 const EdgeArray<bool> *forbiddenEdgeOrig);
00154
00163 void collectAnchorNodes(
00164 node v,
00165 NodeSet &nodes,
00166 const PlanRepExpansion::NodeSplit *nsParent) const;
00167
00176 void findSourcesAndTargets(
00177 node src, node tgt,
00178 NodeSet &sources,
00179 NodeSet &targets) const;
00180
00187 void anchorNodes(
00188 node vOrig,
00189 NodeSet &nodes) const;
00190
00191 static node commonDummy(
00192 NodeSet &sources,
00193 NodeSet &targets);
00194
00202 void insert(List<Crossing> &eip, AnchorNodeInfo &vStart, AnchorNodeInfo &vEnd);
00203
00204 node prepareAnchorNode(
00205 const AnchorNodeInfo &anchor,
00206 node vOrig,
00207 bool isSrc,
00208 edge &eExtra);
00209
00210 void preprocessInsertionPath(
00211 const AnchorNodeInfo &srcInfo,
00212 const AnchorNodeInfo &tgtInfo,
00213 node srcOrig,
00214 node tgtOrig,
00215 node &src,
00216 node &tgt,
00217 edge &eSrc,
00218 edge &eTgt);
00219
00220 node preparePath(
00221 node vAnchor,
00222 adjEntry adjPath,
00223 bool bOrigEdge,
00224 node vOrig);
00225
00226 void findPseudos(
00227 node vDummy,
00228 adjEntry adjSrc,
00229 AnchorNodeInfo &infoSrc,
00230 SListPure<node> &pseudos);
00231
00232 void insertWithCommonDummy(
00233 edge eOrig,
00234 node vDummy,
00235 node &src,
00236 node &tgt);
00237
00245 bool dfsVertex(node v,
00246 int parent,
00247 List<Crossing> &eip,
00248 AnchorNodeInfo &vStart,
00249 AnchorNodeInfo &vEnd);
00250
00259 bool dfsBlock(int i,
00260 node parent,
00261 node &repS,
00262 List<Crossing> &eip,
00263 AnchorNodeInfo &vStart,
00264 AnchorNodeInfo &vEnd);
00265
00266 bool pathSearch(node v, edge parent, const Block &BC, List<edge> &path);
00267
00276 void blockInsert(
00277 Block &BC,
00278 List<Crossing> &L,
00279 AnchorNodeInfo &srcInfo,
00280 AnchorNodeInfo &tgtInfo);
00281
00282 void buildSubpath(
00283 node v,
00284 edge eIn,
00285 edge eOut,
00286 Paths &paths,
00287 bool &bPathToEdge,
00288 bool &bPathToSrc,
00289 bool &bPathToTgt,
00290 ExpandedSkeleton &Exp);
00291
00292 void contractSplitIfReq(node u);
00293 void convertDummy(
00294 node u,
00295 node vOrig,
00296 PlanRepExpansion::nodeSplit ns_0);
00297
00298 void writeEip(const List<Crossing> &eip);
00299
00300 RemoveReinsertType m_rrOption;
00301 double m_percentMostCrossed;
00302
00303 PlanRepExpansion *m_pPG;
00304
00305 NodeSet *m_pSources;
00306 NodeSet *m_pTargets;
00307
00308 NodeArray<SList<int> > m_compV;
00309 Array<SList<node> > m_nodeB;
00310 Array<SList<edge> > m_edgeB;
00311 NodeArray<node> m_GtoBC;
00312
00313 bool m_conFinished;
00314 const EdgeArray<bool> *m_forbiddenEdgeOrig;
00315 };
00316
00317 }
00318
00319 #endif