Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
HierarchyLevels.h
Go to the documentation of this file.
1
32#pragma once
33
38#include <ogdf/layered/Level.h>
39
40namespace ogdf {
41
43
47public:
48 friend class Level;
49 friend class LayerBasedUPRLayout;
50
51private:
52 const Hierarchy& m_H;
53
56
59
61
63
64public:
65 explicit HierarchyLevels(const Hierarchy& H);
67
68 const Hierarchy& hierarchy() const override { return m_H; }
69
71 TraversingDir direction() const { return m_direction; }
72
74 void direction(TraversingDir dir) { m_direction = dir; }
75
77 int size() const override { return m_pLevel.size(); }
78
80 int high() const override { return m_pLevel.high(); }
81
83 int pos(node v) const override { return m_pos[v]; }
84
86 const Array<node>& adjNodes(node v) const {
87 return (m_direction == TraversingDir::downward) ? m_lowerAdjNodes[v] : m_upperAdjNodes[v];
88 }
89
91 const Array<node>& adjNodes(node v, TraversingDir dir) const override {
92 return (dir == TraversingDir::downward) ? m_lowerAdjNodes[v] : m_upperAdjNodes[v];
93 }
94
96 const Level& adjLevel(int i) const {
97 return (m_direction == TraversingDir::downward) ? *m_pLevel[i - 1] : *m_pLevel[i + 1];
98 }
99
101 const Level& operator[](int i) const override { return *m_pLevel[i]; }
102
104 Level& operator[](int i) { return *m_pLevel[i]; }
105
107 int calculateCrossingsSimDraw(int i, const EdgeArray<uint32_t>* edgeSubGraphs) const;
109 int calculateCrossingsSimDraw(const EdgeArray<uint32_t>* edgeSubGraphs) const;
110
115
117 void permute();
118
119 template<class RNG>
120 void permute(RNG& rng);
121
123 void separateCCs(int numCC, const NodeArray<int>& component);
124
126
127 void print(std::ostream& os) const;
128
129 void buildAdjNodes(int i);
131
132 void check() const;
133
134private:
136
138};
139
140template<class RNG>
142 for (int i = 0; i < m_pLevel.high(); ++i) {
143 Level& level = *m_pLevel[i];
144 level.m_nodes.permute(rng);
145 for (int j = 0; j <= level.high(); ++j) {
146 m_pos[level[j]] = j;
147 }
148 }
149
151}
152
153}
Declaration of interfaces used in Sugiyama framework.
Declaration and implementation of EdgeArray class.
Declaration of graph copy classes.
Declaration of Hierarchy class.
Declaration and implementation of Level class.
The parameterized class Array implements dynamic arrays of type E.
Definition Array.h:214
INDEX high() const
Returns the maximal array index.
Definition Array.h:294
void permute(INDEX l, INDEX r)
Randomly permutes the subarray with index set [l..r].
Definition Array.h:516
INDEX size() const
Returns the size (number of elements) of the array.
Definition Array.h:297
Dynamic arrays indexed with edges.
Definition EdgeArray.h:125
Representation of proper hierarchies used by Sugiyama-layout.
Definition Hierarchy.h:43
Representation of proper hierarchies used by Sugiyama-layout.
Array< Level * > m_pLevel
The array of all levels.
const Array< node > & adjNodes(node v, TraversingDir dir) const override
Returns the adjacent nodes of v.
void separateCCs(int numCC, const NodeArray< int > &component)
Adjusts node positions such that nodes are ordered according to components numbers.
NodeArray< Array< node > > m_upperAdjNodes
(Sorted) adjacent nodes on upper level.
NodeArray< int > m_pos
The position of a node on its level.
const Level & operator[](int i) const override
Returns the i-th level.
NodeArray< Array< node > > m_lowerAdjNodes
(Sorted) adjacent nodes on lower level.
void storePos(NodeArray< int > &oldPos) const
Stores the position of nodes in oldPos.
Level & operator[](int i)
Returns the i-th level.
int size() const override
Returns the number of levels.
NodeArray< int > m_nSet
(Only used by buildAdjNodes().)
void permute()
Permutes the order of nodes on each level.
bool transpose(node v)
const Array< node > & adjNodes(node v) const
Returns the adjacent nodes of v (according to direction()).
int calculateCrossingsSimDraw(const EdgeArray< uint32_t > *edgeSubGraphs) const
Computes the total number of crossings (for simultaneous drawing).
void buildAdjNodes(int i)
const Hierarchy & hierarchy() const override
void restorePos(const NodeArray< int > &newPos)
Restores the position of nodes from newPos.
void direction(TraversingDir dir)
Sets the current direction of layer-by-layer sweep.
int high() const override
Returns the maximal array index of a level (= size()-1).
const Level & adjLevel(int i) const
Returns the adjacent level of level i (according to direction()).
TraversingDir direction() const
Returns the current direction of layer-by-layer sweep.
TraversingDir m_direction
The current direction of layer-by-layer sweep.
int calculateCrossingsSimDraw(int i, const EdgeArray< uint32_t > *edgeSubGraphs) const
Computes the number of crossings between level i and i+1 (for simultaneous drawing).
HierarchyLevels(const Hierarchy &H)
void print(std::ostream &os) const
int pos(node v) const override
Returns the position of node v on its level.
const Hierarchy & m_H
int transposePart(const Array< node > &adjV, const Array< node > &adjW)
Representation of levels in hierarchies.
Definition Level.h:60
int high() const override
Returns the maximal array index (= size()-1).
Definition Level.h:92
Array< node > m_nodes
The nodes on this level.
Definition Level.h:65
Dynamic arrays indexed with nodes.
Definition NodeArray.h:125
Class for the representation of nodes.
Definition Graph_d.h:177
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition config.h:101
#define OGDF_MALLOC_NEW_DELETE
Makes the class use malloc for memory allocation.
Definition memory.h:91
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.