Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
Level.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/Graph.h>
35#include <ogdf/basic/SList.h>
36#include <ogdf/basic/tuples.h>
38
39namespace ogdf {
40
41class HierarchyLevels;
42class LayerBasedUPRLayout;
43
44template<class T = double>
47
48public:
50
51 bool less(node v, node w) const { return (*m_pWeight)[v] < (*m_pWeight)[w]; }
52
53 bool operator()(node v, node w) const { return (*m_pWeight)[v] < (*m_pWeight)[w]; }
54};
55
57
60class OGDF_EXPORT Level : public LevelBase {
61 friend class HierarchyLevels;
63 friend class LayerBasedUPRLayout;
64
67 int m_index;
68
69public:
71
76 Level(HierarchyLevels* pLevels, int index, int num)
77 : m_nodes(num), m_pLevels(pLevels), m_index(index) { }
78
79 // destruction
80 ~Level() { }
81
83 const node& operator[](int i) const override { return m_nodes[i]; }
84
86 node& operator[](int i) override { return m_nodes[i]; }
87
89 int size() const override { return m_nodes.size(); }
90
92 int high() const override { return m_nodes.high(); }
93
95 int index() const { return m_index; }
96
98 const Array<node>& adjNodes(node v) const;
99
101 const HierarchyLevels& levels() const { return *m_pLevels; }
102
104 void swap(int i, int j);
105
107 void sort(NodeArray<double>& weight);
108
110 void sort(NodeArray<int>& weight, int minBucket, int maxBucket);
111
114
116 template<class C>
118 m_nodes.quicksort(orderComparer);
119 recalcPos();
120 }
121
122 void recalcPos();
123
124 friend std::ostream& operator<<(std::ostream& os, const Level& L) {
125 os << L.m_nodes;
126 return os;
127 }
128
129private:
132
134};
135
136}
Declaration of interfaces used in Sugiyama framework.
Includes declaration of graph class.
Declaration of singly linked lists and iterators.
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 quicksort()
Sorts array using Quicksort.
Definition Array.h:634
INDEX size() const
Returns the size (number of elements) of the array.
Definition Array.h:297
Interface of hierarchy layout algorithms.
Representation of proper hierarchies used by Sugiyama-layout.
Representation of levels in hierarchies.
Representation of levels in hierarchies.
Definition Level.h:60
const HierarchyLevels & levels() const
Returns the hierarchy to which this level belongs.
Definition Level.h:101
void getIsolatedNodes(SListPure< Tuple2< node, int > > &isolated) const
int m_index
The index of this level.
Definition Level.h:67
void setIsolatedNodes(SListPure< Tuple2< node, int > > &isolated)
void recalcPos()
void sortByWeightOnly(NodeArray< double > &weight)
Sorts the nodes according to weight (without special placement for "isolated" nodes).
void swap(int i, int j)
Exchanges nodes at position i and j.
node & operator[](int i) override
Returns the node at position i.
Definition Level.h:86
void sort(NodeArray< double > &weight)
Sorts the nodes according to weight using quicksort.
void sort(NodeArray< int > &weight, int minBucket, int maxBucket)
Sorts the nodes according to weight using bucket sort.
int index() const
Returns the array index of this level in the hierarchy.
Definition Level.h:95
void sortOrder(C &orderComparer)
Sorts the nodes according to orderComparer.
Definition Level.h:117
friend std::ostream & operator<<(std::ostream &os, const Level &L)
Definition Level.h:124
const node & operator[](int i) const override
Returns the node at position i.
Definition Level.h:83
const Array< node > & adjNodes(node v) const
Returns the (sorted) array of adjacent nodes of v (according to direction()).
Level(HierarchyLevels *pLevels, int index, int num)
Creates a level with index index in hierarchy pLevels.
Definition Level.h:76
int high() const override
Returns the maximal array index (= size()-1).
Definition Level.h:92
HierarchyLevels * m_pLevels
The hierarchy to which this level belongs.
Definition Level.h:66
int size() const override
Returns the number of nodes on this level.
Definition Level.h:89
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
Singly linked lists.
Definition SList.h:179
Tuples of two elements (2-tuples).
Definition tuples.h:46
const NodeArray< T > * m_pWeight
Definition Level.h:46
bool less(node v, node w) const
Definition Level.h:51
WeightComparer(const NodeArray< T > *pWeight)
Definition Level.h:49
bool operator()(node v, node w) const
Definition Level.h:53
#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.
Declaration and implementation of class Tuple2, Tuple3 and Tuple4.