Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

ShellingOrder.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/NodeArray.h>
35 
36 
37 namespace ogdf {
38 
39 
43 class ShellingOrderSet : public Array<node>
44 {
45 public:
48  {
49  m_leftVertex = m_rightVertex = nullptr;
50  m_leftAdj = m_rightAdj = nullptr;
51  }
52 
54 
59  ShellingOrderSet(int n, adjEntry adjL = nullptr, adjEntry adjR = nullptr) : Array<node>(1, n)
60  {
61  m_leftVertex = (adjL != nullptr) ? adjL->twinNode() : nullptr;
62  m_rightVertex = (adjR != nullptr) ? adjR->twinNode() : nullptr;
63  m_leftAdj = adjL;
64  m_rightAdj = adjR;
65  }
66 
67 
69  node left() const {
70  return m_leftVertex;
71  }
72 
74  node right() const {
75  return m_rightVertex;
76  }
77 
79  adjEntry leftAdj() const {
80  return m_leftAdj;
81  }
82 
84  adjEntry rightAdj() const {
85  return m_rightAdj;
86  }
87 
89  bool hasLeft() const {
90  return m_leftAdj != nullptr;
91  }
92 
94  bool hasRight() const {
95  return m_rightAdj != nullptr;
96  }
97 
99  void left(node cl) {
100  m_leftVertex = cl;
101  }
102 
104  void right (node cr) {
105  m_rightVertex = cr;
106  }
107 
109  void leftAdj(adjEntry adjL) {
110  m_leftAdj = adjL;
111  }
112 
114  void rightAdj(adjEntry adjR) {
115  m_rightAdj = adjR;
116  }
117 
119  int len() const {
120  return high();
121  }
122 
124  node operator[] (const int i) const {
125  return Array<node>::operator[](i);
126  }
127 
129  node& operator[] (const int i) {
130  return Array<node>::operator[](i);
131  }
132 
133 
134 private:
139 };
140 
145 {
146 public:
147 
150  m_pGraph = nullptr;
151  }
152 
153 #if 0
154  ShellingOrder(const Graph &G, const List<ShellingOrderSet> &partition);
155 #endif
156 
158 
160  const Graph& getGraph() const {
161  return *m_pGraph;
162  }
163 
165  int length() const {
166  return m_V.high();
167  }
168 
170  int len(int i) const {
171  return m_V[i].len();
172  }
173 
175  node operator() (int i, int j) const {
176  return (m_V[i])[j];
177  }
178 
180  const ShellingOrderSet& operator[](int i) const {
181  return m_V[i];
182  }
183 
185  node left (int i) const {
186  return m_V[i].left();
187  }
188 
190  node right (int i) const {
191  return m_V[i].right();
192  }
193 
195  int rank (node v) const {
196  return m_rank[v];
197  }
198 
199 
205  void init(const Graph &G, const List<ShellingOrderSet> &partition);
206 
212  void initLeftmost(const Graph &G, const List<ShellingOrderSet> &partition);
213 
214 
215  void push(int k, node v, node tgt);
216 
217  friend class CompOrderBic;
218 
219 private:
220  const Graph *m_pGraph;
223 };
224 
225 }
The node set in a shelling order of a graph.
Definition: ShellingOrder.h:43
The parameterized class Array implements dynamic arrays of type E.
Definition: Array.h:200
bool hasLeft() const
Returns true iff the adjacency entry to the left-node exists.
Definition: ShellingOrder.h:89
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:492
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
void init()
Reinitializes the array to an array with empty index set.
Definition: Array.h:354
ShellingOrder()
Creates an empty shelling order.
int high() const
Returns the maximal array index.
Definition: Array.h:279
adjEntry rightAdj() const
Returns the adjacency entry pointing from zp to the right node (or 0 if no such node).
Definition: ShellingOrder.h:84
NodeArray< int > m_rank
the rank of nodes.
node m_rightVertex
the right-node of the set.
node operator[](const int i) const
Returns the i-th node in the order set from left (the leftmost node has index 1). ...
node left() const
Returns the left-node of the set.
Definition: ShellingOrder.h:69
int length() const
Returns the number of sets in the node partition.
void right(node cr)
Sets the right-node to cr.
ShellingOrderSet(int n, adjEntry adjL=nullptr, adjEntry adjR=nullptr)
Creates a shelling order set for n nodes.
Definition: ShellingOrder.h:59
void left(node cl)
Sets the left-node to cl.
Definition: ShellingOrder.h:99
const Graph * m_pGraph
the associated graph.
bool hasRight() const
Returns true iff the adjacency entry to the right-node exists.
Definition: ShellingOrder.h:94
adjEntry leftAdj() const
Returns the adjacency entry pointing from z1 to the left node (or 0 if no such node).
Definition: ShellingOrder.h:79
void leftAdj(adjEntry adjL)
Sets the adjacency entry pointing to the left-node to adjL.
Doubly linked lists (maintaining the length of the list).
Definition: List.h:40
const Graph & getGraph() const
Returns the graph associated with the shelling order.
node left(int i) const
Returns the left-node of the i-th set Vi.
adjEntry m_leftAdj
the adjacency entry pointing to the left-node.
node right(int i) const
Returns the right-node of the i-th set Vi.
Class for the representation of nodes.
Definition: Graph_d.h:169
Declaration and implementation of NodeArray class.
Array< ShellingOrderSet > m_V
the node partition.
The shelling order of a graph.
void rightAdj(adjEntry adjR)
Sets the adjacency entry pointing to the right-node to adjR.
adjEntry m_rightAdj
the adjacency entry pointing to the right-node.
node right() const
Returns the right-node of the set.
Definition: ShellingOrder.h:74
node m_leftVertex
the left-node of the set.
int rank(node v) const
Returns the rank of node v, where rank(v) = i iff v is contained in Vi.
const_reference operator[](INDEX i) const
Returns a reference to the element at position i.
Definition: Array.h:288
The namespace for all OGDF objects.
ShellingOrderSet()
Creates an empty shelling order set.
Definition: ShellingOrder.h:47
Class for adjacency list elements.
Definition: Graph_d.h:79
int len() const
Returns the length of the order set, i.e., the number of contained nodes.
const ShellingOrderSet & operator[](int i) const
Returns the i-th set V_i
int len(int i) const
Returns the length of the i-th order set Vi.