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
34#include <ogdf/basic/Array.h>
35#include <ogdf/basic/Graph.h>
36#include <ogdf/basic/basic.h>
37#include <ogdf/basic/memory.h>
39#include <ogdf/layered/Level.h>
40
41#include <cstdint>
42#include <iosfwd>
43
44namespace ogdf {
45class Hierarchy;
46
48
52public:
53 friend class Level;
54 friend class LayerBasedUPRLayout;
55
56private:
57 const Hierarchy& m_H;
58
61
64
66
68
69public:
70 explicit HierarchyLevels(const Hierarchy& H);
72
73 const Hierarchy& hierarchy() const override { return m_H; }
74
76 TraversingDir direction() const { return m_direction; }
77
79 void direction(TraversingDir dir) { m_direction = dir; }
80
82 int size() const override { return m_pLevel.size(); }
83
85 int high() const override { return m_pLevel.high(); }
86
88 int pos(node v) const override { return m_pos[v]; }
89
91 const Array<node>& adjNodes(node v) const {
92 return (m_direction == TraversingDir::downward) ? m_lowerAdjNodes[v] : m_upperAdjNodes[v];
93 }
94
96 const Array<node>& adjNodes(node v, TraversingDir dir) const override {
97 return (dir == TraversingDir::downward) ? m_lowerAdjNodes[v] : m_upperAdjNodes[v];
98 }
99
101 const Level& adjLevel(int i) const {
102 return (m_direction == TraversingDir::downward) ? *m_pLevel[i - 1] : *m_pLevel[i + 1];
103 }
104
106 const Level& operator[](int i) const override { return *m_pLevel[i]; }
107
109 Level& operator[](int i) { return *m_pLevel[i]; }
110
112 int calculateCrossingsSimDraw(int i, const EdgeArray<uint32_t>* edgeSubGraphs) const;
114 int calculateCrossingsSimDraw(const EdgeArray<uint32_t>* edgeSubGraphs) const;
115
117 void storePos(NodeArray<int>& oldPos) const;
119 void restorePos(const NodeArray<int>& newPos);
120
122 void permute();
123
124 template<class RNG>
125 void permute(RNG& rng);
126
128 void separateCCs(int numCC, const NodeArray<int>& component);
129
131
132 void print(std::ostream& os) const;
133
134 void buildAdjNodes(int i);
136
137 void check() const;
138
139private:
140 int transposePart(const Array<node>& adjV, const Array<node>& adjW);
141
143};
144
145template<class RNG>
147 for (int i = 0; i < m_pLevel.high(); ++i) {
148 Level& level = *m_pLevel[i];
149 level.m_nodes.permute(rng);
150 for (int j = 0; j <= level.high(); ++j) {
151 m_pos[level[j]] = j;
152 }
153 }
154
156}
157
158}
Declaration and implementation of Array class and Array algorithms.
Declaration of interfaces used in Sugiyama framework.
Includes declaration of graph class.
Declaration and implementation of Level class.
Basic declarations, included by all source files.
The parameterized class Array implements dynamic arrays of type E.
Definition Array.h:219
INDEX high() const
Returns the maximal array index.
Definition Array.h:299
void permute(INDEX l, INDEX r)
Randomly permutes the subarray with index set [l..r].
Definition Array.h:521
INDEX size() const
Returns the size (number of elements) of the array.
Definition Array.h:302
Representation of proper hierarchies used by Sugiyama-layout.
Definition Hierarchy.h:47
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:66
int high() const override
Returns the maximal array index (= size()-1).
Definition Level.h:98
Array< node > m_nodes
The nodes on this level.
Definition Level.h:71
Class for the representation of nodes.
Definition Graph_d.h:241
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition Graph_d.h:717
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition Graph_d.h:659
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
#define OGDF_MALLOC_NEW_DELETE
Makes the class use malloc for memory allocation.
Definition memory.h:92
Declaration of memory manager for allocating small pieces of memory.
The namespace for all OGDF objects.