Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

LayerBasedUPRLayout.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/Array.h>
35 #include <ogdf/basic/ArrayBuffer.h>
36 #include <ogdf/basic/Graph.h>
37 #include <ogdf/basic/List.h>
38 #include <ogdf/basic/basic.h>
44 
45 #include <memory>
46 
47 namespace ogdf {
48 class GraphAttributes;
49 class Hierarchy;
50 class HierarchyLevels;
51 class UpwardPlanRep;
52 template<class E>
53 class SListPure;
54 
56 public:
57  OrderComparer(const UpwardPlanRep& _UPR, Hierarchy& _H);
58 
64  bool less(node vH1, node vH2) const;
65 
66 private:
70 #if 0
71  EdgeArray<int> outEdgeOrder;
72 #endif
74 
76  void dfs_LR(edge e, NodeArray<bool>& visited, NodeArray<int>& dfsNum, int& num);
77 
79  bool left(node vUPR1,
80  const List<edge>& chain1,
81  node vUPR2,
82  const List<edge>& chain2
83  ) const;
84 
91  bool left(edge e1UPR, edge e2UPR) const;
92 
100  bool left(List<edge>& chain1, List<edge>& chain2, int level) const;
101 
103  bool checkUp(node vUPR, int level) const;
104 };
105 
110 public:
111  // constructor: sets options to default values
113  // set default value
115  fhl->nodeDistance(40.0);
116  fhl->layerDistance(40.0);
117  fhl->fixedLayerDistance(true);
118  m_layout.reset(fhl);
119  OptimalRanking* opRank = new OptimalRanking();
120  opRank->separateMultiEdges(false);
121  m_ranking.reset(opRank);
122  m_numLevels = 0;
123  m_maxLevelSize = 0;
124  }
125 
126  // destructor
128 
129  // returns the number of crossings in the layout after the algorithm
130  // has been applied
131  int numberOfCrossings() const { return m_crossings; }
132 
133  // module option for the computation of the final layout
134  void setLayout(HierarchyLayoutModule* pLayout) { m_layout.reset(pLayout); }
135 
136  void setRanking(RankingModule* pRanking) { m_ranking.reset(pRanking); }
137 
139  void UPRLayoutSimple(const UpwardPlanRep& UPR, GraphAttributes& AG);
140 
142  int numberOfLayers() { return m_numLevels; }
143 
145  int maxLayerSize() { return m_maxLevelSize; }
146 
147 protected:
148  /*
149  * @param UPR is the upward planarized representation of the input graph.
150  * @param AG has to be assigned the hierarchy layout.
151  */
152  virtual void doCall(const UpwardPlanRep& UPR, GraphAttributes& AG) override;
153 
155 
156  std::unique_ptr<RankingModule> m_ranking;
157 
158  std::unique_ptr<HierarchyLayoutModule> m_layout;
159 
160 private:
161  // compute a ranking of the nodes of UPR.
162  // Precond. a ranking module muss be set
163  void computeRanking(const UpwardPlanRep& UPR, NodeArray<int>& rank);
164 
165 
167  void postProcessing_sourceReorder(HierarchyLevels& levels, List<node>& sources);
168 
170  void postProcessing_reduceLED(Hierarchy& H, HierarchyLevels& levels, const List<node>& sources) {
171  for (node s : sources) {
172  postProcessing_reduceLED(H, levels, s);
173  }
174  }
175 
176  void postProcessing_reduceLED(Hierarchy& H, HierarchyLevels& levels, node vH);
177 
178  void post_processing_reduce(Hierarchy& H, HierarchyLevels& levels, int& i, node s, int minIdx,
179  int maxIdx, NodeArray<bool>& markedNodes);
180 
182  void postProcessing_markUp(HierarchyLevels& levels, node sH, NodeArray<bool>& markedNodes);
183 
184 
186  void post_processing_deleteLvl(Hierarchy& H, HierarchyLevels& levels, int i);
187 
189  void post_processing_deleteInterval(Hierarchy& H, HierarchyLevels& levels, int beginIdx,
190  int endIdx, int& j);
191 
193  void post_processing_CopyInterval(Hierarchy& H, HierarchyLevels& levels, int i, int beginIdx,
194  int endIdx, int pos);
195 
199 
200 
203 
204  void callSimple(GraphAttributes& AG, adjEntry adj //left most edge of the source
205  );
206 
207  // needed for UPRLayoutSimple
208  void dfsSortLevels(adjEntry adj1, const NodeArray<int>& rank, Array<SListPure<node>>& nodes);
209 
210  // needed for UPRLayoutSimple
211  void longestPathRanking(const Graph& G, NodeArray<int>& rank);
212 
214 };
215 
216 }
ogdf::ArrayBuffer
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
Definition: Array.h:53
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:72
ArrayBuffer.h
Declaration and implementation of ArrayBuffer class.
Graph.h
Includes declaration of graph class.
ogdf::FastHierarchyLayout::nodeDistance
double nodeDistance() const
Returns the option node distance.
Definition: FastHierarchyLayout.h:98
ogdf::OptimalRanking::separateMultiEdges
bool separateMultiEdges() const
Returns the current setting of option separateMultiEdges.
Definition: OptimalRanking.h:122
RankingModule.h
Declaration of interface for ranking algorithms.
ogdf::OptimalRanking
The optimal ranking algorithm.
Definition: OptimalRanking.h:76
ogdf::LayerBasedUPRLayout::setRanking
void setRanking(RankingModule *pRanking)
Definition: LayerBasedUPRLayout.h:136
ogdf::OrderComparer
Definition: LayerBasedUPRLayout.h:55
ogdf::OrderComparer::left
bool left(node vUPR1, const List< edge > &chain1, node vUPR2, const List< edge > &chain2) const
Returns true if vUPR1 is on the left-hand side of vUPR2 according to m_UPR.
ogdf::HierarchyLayoutModule
Interface of hierarchy layout algorithms.
Definition: HierarchyLayoutModule.h:52
ogdf::LayerBasedUPRLayout::m_ranking
std::unique_ptr< RankingModule > m_ranking
Definition: LayerBasedUPRLayout.h:156
ogdf::LayerBasedUPRLayout::m_crossings
int m_crossings
Definition: LayerBasedUPRLayout.h:154
ogdf::FastHierarchyLayout::fixedLayerDistance
bool fixedLayerDistance() const
Returns the option fixed layer distance.
Definition: FastHierarchyLayout.h:110
ogdf::Hierarchy
Representation of proper hierarchies used by Sugiyama-layout.
Definition: Hierarchy.h:47
ogdf::UPRLayoutModule
Interface of hierarchy layout algorithms.
Definition: UPRLayoutModule.h:46
ogdf::RankingModule
Interface of algorithms for computing a node ranking.
Definition: RankingModule.h:46
ogdf::LayerBasedUPRLayout::m_layout
std::unique_ptr< HierarchyLayoutModule > m_layout
Definition: LayerBasedUPRLayout.h:158
ogdf::OrderComparer::less
bool less(node vH1, node vH2) const
Returns true iff vH1 and vH2 are placed on the same layer and node vH1 has to drawn on the left-hand ...
ogdf::AdjElement
Class for adjacency list elements.
Definition: Graph_d.h:142
ogdf::OrderComparer::m_UPR
const UpwardPlanRep & m_UPR
Definition: LayerBasedUPRLayout.h:67
ogdf::LayerBasedUPRLayout::m_numLevels
int m_numLevels
Definition: LayerBasedUPRLayout.h:196
ogdf::LayerBasedUPRLayout::setLayout
void setLayout(HierarchyLayoutModule *pLayout)
Definition: LayerBasedUPRLayout.h:134
OptimalRanking.h
Declaration of optimal ranking algorithm for Sugiyama algorithm.
FastHierarchyLayout.h
declaration and implementation of the third phase of sugiyama
ogdf::OrderComparer::H
Hierarchy & H
Definition: LayerBasedUPRLayout.h:68
ogdf::LayerBasedUPRLayout
Definition: LayerBasedUPRLayout.h:109
ogdf::OrderComparer::checkUp
bool checkUp(node vUPR, int level) const
Returns true iff there is a node above vUPR with rank level or lower.
ogdf::LayerBasedUPRLayout::m_maxLevelSize
int m_maxLevelSize
Definition: LayerBasedUPRLayout.h:197
ogdf::Array
The parameterized class Array implements dynamic arrays of type E.
Definition: Array.h:219
ogdf::FastHierarchyLayout::layerDistance
double layerDistance() const
Returns the option layer distance.
Definition: FastHierarchyLayout.h:104
ogdf::SListPure
Singly linked lists.
Definition: SList.h:52
ogdf::OrderComparer::crossed
NodeArray< bool > crossed
Definition: LayerBasedUPRLayout.h:73
ogdf::List< edge >
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::OrderComparer::OrderComparer
OrderComparer(const UpwardPlanRep &_UPR, Hierarchy &_H)
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::OrderComparer::m_dfsNum
NodeArray< int > m_dfsNum
Definition: LayerBasedUPRLayout.h:69
ogdf::LayerBasedUPRLayout::numberOfLayers
int numberOfLayers()
Return the number of layers/levels. Not implemented if use methode callSimple(..).
Definition: LayerBasedUPRLayout.h:142
ogdf::OrderComparer::dfs_LR
void dfs_LR(edge e, NodeArray< bool > &visited, NodeArray< int > &dfsNum, int &num)
Traverses with dfs using edge order from left to right and compute the dfs number.
ogdf::LayerBasedUPRLayout::~LayerBasedUPRLayout
~LayerBasedUPRLayout()
Definition: LayerBasedUPRLayout.h:127
ogdf::LayerBasedUPRLayout::m_dummies
ArrayBuffer< node > m_dummies
Definition: LayerBasedUPRLayout.h:198
basic.h
Basic declarations, included by all source files.
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
UPRLayoutModule.h
Declaration of interface for layout algorithms for a UpwardPlanRep.
HierarchyLayoutModule.h
Declaration of interface hierarchy layout algorithms (3. phase of Sugiyama).
Array.h
Declaration and implementation of Array class and Array algorithms.
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:363
ogdf::FastHierarchyLayout
Coordinate assignment phase for the Sugiyama algorithm by Buchheim et al.
Definition: FastHierarchyLayout.h:80
List.h
Declaration of doubly linked lists and iterators.
ogdf::UpwardPlanRep
Upward planarized representations (of a connected component) of a graph.
Definition: UpwardPlanRep.h:57
ogdf::LayerBasedUPRLayout::numberOfCrossings
int numberOfCrossings() const
Definition: LayerBasedUPRLayout.h:131
ogdf::LayerBasedUPRLayout::LayerBasedUPRLayout
LayerBasedUPRLayout()
Definition: LayerBasedUPRLayout.h:112
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::LayerBasedUPRLayout::postProcessing_reduceLED
void postProcessing_reduceLED(Hierarchy &H, HierarchyLevels &levels, const List< node > &sources)
reduce the long edge dummies (LED)
Definition: LayerBasedUPRLayout.h:170
ogdf::HierarchyLevels
Representation of proper hierarchies used by Sugiyama-layout.
Definition: HierarchyLevels.h:51
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:716
ogdf::LayerBasedUPRLayout::maxLayerSize
int maxLayerSize()
Return the max. number of elements on a layer. Not implemented if use methode callSimple(....
Definition: LayerBasedUPRLayout.h:145