Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00041 #ifdef _MSC_VER
00042 #pragma once
00043 #endif
00044
00045 #ifndef OGDF_LAYER_BASED_UPR_LAYOUT_H
00046 #define OGDF_LAYER_BASED_UPR_LAYOUT_H
00047
00048
00049
00050 #include <ogdf/basic/ModuleOption.h>
00051 #include <ogdf/upward/UpwardPlanRep.h>
00052 #include <ogdf/module/RankingModule.h>
00053 #include <ogdf/module/UPRLayoutModule.h>
00054 #include <ogdf/module/HierarchyLayoutModule.h>
00055 #include <ogdf/layered/OptimalHierarchyLayout.h>
00056 #include <ogdf/layered/FastHierarchyLayout.h>
00057 #include <ogdf/layered/OptimalRanking.h>
00058
00059
00060 namespace ogdf {
00061
00062 class OrderComparer
00063 {
00064 public:
00065 OrderComparer(const UpwardPlanRep &_UPR, Hierarchy &_H);
00066
00067
00068 bool less(node vH1, node vH2) const ;
00069
00070 private:
00071 const UpwardPlanRep &UPR;
00072 Hierarchy &H;
00073 NodeArray<int> dfsNum;
00074
00075 mutable NodeArray<bool> crossed;
00076
00077
00078 void dfs_LR( edge e,
00079 NodeArray<bool> &visited,
00080 NodeArray<int> &dfsNum,
00081 int &num);
00082
00083
00084 bool left(node vUPR1,
00085 List<edge> chain1,
00086 node vUPR2 ,
00087 List<edge> chain2
00088 ) const;
00089
00090
00091
00092 bool left(edge e1UPR, edge e2UPR) const;
00093
00094
00095
00096
00097 bool left(List<edge> &chain1, List<edge> &chain2, int level) const;
00098
00099
00100 bool checkUp(node vUPR, int level) const;
00101 };
00102
00103
00104 class OGDF_EXPORT LayerBasedUPRLayout : public UPRLayoutModule
00105 {
00106 public:
00107
00108
00109 LayerBasedUPRLayout()
00110 {
00111
00112 FastHierarchyLayout *fhl = new FastHierarchyLayout();
00113 fhl->nodeDistance(40.0);
00114 fhl->layerDistance(40.0);
00115 fhl->fixedLayerDistance(true);
00116 m_layout.set(fhl);
00117 OptimalRanking *opRank = new OptimalRanking();
00118 opRank->separateMultiEdges(false);
00119 m_ranking.set(opRank);
00120 m_numLevels = 0;
00121 m_maxLevelSize = 0;
00122 }
00123
00124
00125 ~LayerBasedUPRLayout() { }
00126
00127
00128
00129 int numberOfCrossings() const { return m_crossings; }
00130
00131
00132 void setLayout(HierarchyLayoutModule *pLayout) {
00133 m_layout.set(pLayout);
00134 }
00135
00136
00137 void setRanking(RankingModule *pRanking) {
00138 m_ranking.set(pRanking);
00139 }
00140
00142 void UPRLayoutSimple(const UpwardPlanRep &UPR, GraphAttributes &AG);
00143
00145 int numberOfLayers() { return m_numLevels; }
00146
00148 int maxLayerSize() { return m_maxLevelSize; }
00149
00150 protected :
00151
00152
00153
00154
00155
00156 virtual void doCall(const UpwardPlanRep &UPR, GraphAttributes &AG);
00157
00158 int m_crossings;
00159
00160 ModuleOption<RankingModule> m_ranking;
00161
00162 ModuleOption<HierarchyLayoutModule> m_layout;
00163
00164
00165 struct RankComparer {
00166 Hierarchy *H;
00167 bool less(node v1, node v2) const {
00168 return (H->rank(v1) < H->rank(v2));
00169 }
00170 };
00171
00172
00173 private:
00174
00175
00176
00177 void computeRanking(const UpwardPlanRep &UPR, NodeArray<int> &rank);
00178
00179
00181 void postProcessing_sourceReorder(Hierarchy &H, List<node> &sources);
00182
00183
00185 void postProcessing_reduceLED(Hierarchy &H, List<node> &sources) {
00186 forall_listiterators(node, it, sources)
00187 postProcessing_reduceLED(H, *it);
00188 }
00189
00190 void postProcessing_reduceLED(Hierarchy &H, node vH);
00191
00192 void post_processing_reduce(Hierarchy &H, int &i, node s, int minIdx, int maxIdx, NodeArray<bool> &markedNodes);
00193
00195 void postProcessing_markUp(Hierarchy &H, node sH, NodeArray<bool> &markedNodes);
00196
00197
00199 void post_processing_deleteLvl(Hierarchy &H, int i);
00200
00202 void post_processing_deleteInterval(Hierarchy &H, int beginIdx, int endIdx, int &j);
00203
00205 void post_processing_CopyInterval(Hierarchy &H, int i, int beginIdx, int endIdx, int pos);
00206
00207 int m_numLevels;
00208 int m_maxLevelSize;
00209
00210
00211
00212
00213 void callSimple(GraphAttributes &AG, adjEntry adj
00214 );
00215
00216
00217 void dfsSortLevels(
00218 adjEntry adj1,
00219 const NodeArray<int> &rank,
00220 Array<SListPure<node> > &nodes);
00221
00222
00223 void longestPathRanking(const Graph &G, NodeArray<int> &rank);
00224
00225
00226 };
00227
00228 }
00229
00230 #endif