Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

HierarchyLevels.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/EdgeArray.h>
35 #include <ogdf/layered/Level.h>
36 #include <ogdf/basic/GraphCopy.h>
37 #include <ogdf/layered/Hierarchy.h>
39 
40 namespace ogdf {
41 
43 
47 
48 public:
49 
50  friend class Level;
51  friend class LayerBasedUPRLayout;
52 
53 private:
54  const Hierarchy &m_H;
55 
58 
61 
63 
64  TraversingDir m_direction;
65 
66 public:
67  explicit HierarchyLevels(const Hierarchy &H);
68  ~HierarchyLevels();
69 
70  const Hierarchy &hierarchy() const override { return m_H; }
71 
73  TraversingDir direction() const {
74  return m_direction;
75  }
76 
78  void direction (TraversingDir dir) {
79  m_direction = dir;
80  }
81 
83  int size() const override { return m_pLevel.size(); }
84 
86  int high() const override { return m_pLevel.high(); }
87 
89  int pos(node v) const override { return m_pos[v]; }
90 
92  const Array<node> &adjNodes(node v) const {
93  return (m_direction == TraversingDir::downward) ? m_lowerAdjNodes[v] :
94  m_upperAdjNodes[v];
95  }
96 
98  const Array<node> &adjNodes(node v, TraversingDir dir) const override {
99  return (dir == TraversingDir::downward) ? m_lowerAdjNodes[v] :
100  m_upperAdjNodes[v];
101  }
102 
104  const Level &adjLevel(int i) const {
105  return (m_direction == TraversingDir::downward) ? *m_pLevel[i-1] : *m_pLevel[i+1];
106  }
107 
109  const Level &operator[](int i) const override { return *m_pLevel[i]; }
110 
112  Level &operator[](int i) { return *m_pLevel[i]; }
113 
115  int calculateCrossingsSimDraw(int i, const EdgeArray<uint32_t> *edgeSubGraphs) const;
117  int calculateCrossingsSimDraw(const EdgeArray<uint32_t> *edgeSubGraphs) const;
118 
120  void storePos (NodeArray<int> &oldPos) const;
122  void restorePos (const NodeArray<int> &newPos);
123 
125  void permute();
126 
127  template<class RNG>
128  void permute(RNG &rng);
129 
131  void separateCCs(int numCC, const NodeArray<int> &component);
132 
133  bool transpose(node v);
134 
135  void print(ostream &os) const;
136 
137  void buildAdjNodes(int i);
138  void buildAdjNodes();
139 
140  void check() const;
141 
142 private:
143  int transposePart(const Array<node> &adjV, const Array<node> &adjW);
144 
146 };
147 
148 
149 template<class RNG>
151 {
152  for(int i = 0; i < m_pLevel.high(); ++i) {
153  Level &level = *m_pLevel[i];
154  level.m_nodes.permute(rng);
155  for(int j = 0; j <= level.high(); ++j)
156  m_pos[level[j]] = j;
157  }
158 
159  buildAdjNodes();
160 }
161 
162 } // end namespace ogdf
The parameterized class Array implements dynamic arrays of type E.
Definition: Array.h:56
NodeArray< Array< node > > m_lowerAdjNodes
(Sorted) adjacent nodes on lower level.
Representation of proper hierarchies used by Sugiyama-layout.
TraversingDir m_direction
The current direction of layer-by-layer sweep.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
void permute()
Permutes the order of nodes on each level.
#define OGDF_MALLOC_NEW_DELETE
Makes the class use malloc for memory allocation.
Definition: memory.h:91
NodeArray< int > m_nSet
(Only used by buildAdjNodes().)
INDEX high() const
Returns the maximal array index.
Definition: Array.h:131
Declaration of interfaces used in Sugiyama framework.
int high() const override
Returns the maximal array index (= size()-1).
Definition: Level.h:93
const Array< node > & adjNodes(node v) const
Returns the adjacent nodes of v (according to direction()).
Array< Level * > m_pLevel
The array of all levels.
Representation of levels in hierarchies.
Definition: Level.h:61
Declaration of Hierarchy class.
void permute(INDEX l, INDEX r)
Randomly permutes the subarray with index set [l..r].
Definition: Array.h:326
Array< node > m_nodes
The nodes on this level.
Definition: Level.h:67
Declaration and implementation of Level class.
int high() const override
Returns the maximal array index of a level (= size()-1).
Level & operator[](int i)
Returns the i-th level.
const Array< node > & adjNodes(node v, TraversingDir dir) const override
Returns the adjacent nodes of v.
const Hierarchy & m_H
Declaration and implementation of EdgeArray class.
TraversingDir direction() const
Returns the current direction of layer-by-layer sweep.
INDEX size() const
Returns the size (number of elements) of the array.
Definition: Array.h:134
Declaration of graph copy classes.
Class for the representation of nodes.
Definition: Graph_d.h:167
int size() const override
Returns the number of levels.
const Hierarchy & hierarchy() const override
int pos(node v) const override
Returns the position of node v on its level.
void direction(TraversingDir dir)
Sets the current direction of layer-by-layer sweep.
NodeArray< int > m_pos
The position of a node on its level.
The namespace for all OGDF objects.
const Level & operator[](int i) const override
Returns the i-th level.
NodeArray< Array< node > > m_upperAdjNodes
(Sorted) adjacent nodes on upper level.
void print(ostream &os, const Array< E, INDEX > &a, char delim=' ')
Prints array a to output stream os using delimiter delim.
Definition: Array.h:753
const Level & adjLevel(int i) const
Returns the adjacent level of level i (according to direction()).
Representation of proper hierarchies used by Sugiyama-layout.
Definition: Hierarchy.h:44