Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

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 l, adjEntry adjL = nullptr, adjEntry adjR = nullptr) : Array<node>(1,l)
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  // destructor
69 
70 
72  node left() const {
73  return m_leftVertex;
74  }
75 
77  node right() const {
78  return m_rightVertex;
79  }
80 
82  adjEntry leftAdj() const {
83  return m_leftAdj;
84  }
85 
87  adjEntry rightAdj() const {
88  return m_rightAdj;
89  }
90 
92  bool hasLeft() const {
93  return m_leftAdj != nullptr;
94  }
95 
97  bool hasRight() const {
98  return m_rightAdj != nullptr;
99  }
100 
102  void left(node cl) {
103  m_leftVertex = cl;
104  }
105 
107  void right (node cr) {
108  m_rightVertex = cr;
109  }
110 
112  void leftAdj(adjEntry adjL) {
113  m_leftAdj = adjL;
114  }
115 
117  void rightAdj(adjEntry adjR) {
118  m_rightAdj = adjR;
119  }
120 
122  int len() const {
123  return high();
124  }
125 
127  node operator[] (const int i) const {
128  return Array<node>::operator[](i);
129  }
130 
132  node& operator[] (const int i) {
133  return Array<node>::operator[](i);
134  }
135 
139  left (S.left());
140  right (S.right());
141  leftAdj (S.leftAdj());
142  rightAdj(S.rightAdj());
143  return *this;
144  }
145 
146 private:
151 };
152 
153 
154 
155 
160 {
161 public:
162 
165  m_pGraph = nullptr;
166  }
167 
168 #if 0
169  ShellingOrder(const Graph &G, const List<ShellingOrderSet> &partition);
170 #endif
171 
173 
175  const Graph& getGraph() const {
176  return *m_pGraph;
177  }
178 
180  int length() const {
181  return m_V.high();
182  }
183 
185  int len(int i) const {
186  return m_V[i].len();
187  }
188 
190  node operator() (int i, int j) const {
191  return (m_V[i])[j];
192  }
193 
195  const ShellingOrderSet& operator[](int i) const {
196  return m_V[i];
197  }
198 
200  node left (int i) const {
201  return m_V[i].left();
202  }
203 
205  node right (int i) const {
206  return m_V[i].right();
207  }
208 
210  int rank (node v) const {
211  return m_rank[v];
212  }
213 
214 
220  void init(const Graph &G, const List<ShellingOrderSet> &partition);
221 
227  void initLeftmost(const Graph &G, const List<ShellingOrderSet> &partition);
228 
229 
230  void push(int k, node v, node tgt);
231 
232  friend class CompOrderBic;
233 
234 private:
235  const Graph *m_pGraph;
238 };
239 
240 
241 
242 } // end namespace ogdf
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:56
bool hasLeft() const
Returns true iff the adjacency entry to the left-node exists.
Definition: ShellingOrder.h:92
ShellingOrderSet(int l, adjEntry adjL=nullptr, adjEntry adjR=nullptr)
Creates a shelling order set for l nodes.
Definition: ShellingOrder.h:59
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:472
#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:206
ShellingOrder()
Creates an empty shelling order.
int high() const
Returns the maximal array index.
Definition: Array.h:131
adjEntry rightAdj() const
Returns the adjacency entry pointing from zp to the right node (or 0 if no such node).
Definition: ShellingOrder.h:87
NodeArray< int > m_rank
the rank of nodes.
ShellingOrderSet & operator=(const ShellingOrderSet &S)
Assignment operator.
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:72
int length() const
Returns the number of sets in the node partition.
void right(node cr)
Sets the right-node to cr.
void left(node cl)
Sets the left-node to cl.
const Graph * m_pGraph
the associated graph.
bool hasRight() const
Returns true iff the adjacency entry to the right-node exists.
Definition: ShellingOrder.h:97
adjEntry leftAdj() const
Returns the adjacency entry pointing from z1 to the left node (or 0 if no such node).
Definition: ShellingOrder.h:82
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:39
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:167
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:77
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.
Array< E, INDEX > & operator=(const Array< E, INDEX > &A)
Assignment operator.
Definition: Array.h:284
const_reference operator[](INDEX i) const
Returns a reference to the element at position i.
Definition: Array.h:140
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:78
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.