Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
IOPoints.h
Go to the documentation of this file.
1
33#pragma once
34
36
37namespace ogdf {
38
39
41struct InOutPoint {
42 int m_dx, m_dy;
44
46 m_dx = m_dy = 0;
47 m_adj = nullptr;
48 }
49
50 explicit InOutPoint(adjEntry adj) {
51 m_adj = adj;
52 m_dx = m_dy = 0;
53 }
54};
55
57class IOPoints {
58public:
60
61 explicit IOPoints(const Graph& G)
62 : m_depth(G, 0), m_height(G, 0), m_in(G), m_out(G), m_mark(G, false), m_pointOf(G, nullptr) { }
63
65
66 // length of in- or outpoint list
67 int out(node v) const { return m_out[v].size(); }
68
69 int in(node v) const { return m_in[v].size(); }
70
71 // getting a const-reference to in- or outpoint list
72 const List<InOutPoint>& inpoints(node v) const { return m_in[v]; }
73
75
76 const List<InOutPoint>& outpoints(node v) const { return m_out[v]; }
77
79
80 // getting the in-/outpoint belonging to an adjacency entry
81 const InOutPoint* pointOf(adjEntry adj) const { return m_pointOf[adj]; }
82
83 // marking adjacency entries
84 bool marked(adjEntry adj) const { return m_mark[adj]; }
85
86 bool marked(node v) { return v->outdeg() == 1 && marked(v->firstAdj()); }
87
88 // finding outpoints belonging to non-marked edges
92
96
100
104
105 // building in-/outpoint lists
107 node v = adj->theNode();
108 m_pointOf[adj] = &(*m_in[v].pushBack(InOutPoint(adj)));
109 }
110
112 node v = adj->theNode();
113 m_pointOf[adj] = &(*m_out[v].pushBack(InOutPoint(adj)));
114 }
115
117 node v = adj->theNode();
118 m_pointOf[adj] = &(*m_in[v].pushFront(InOutPoint(adj)));
119 }
120
121 // setting relative coordinates
122 void setOutCoord(ListIterator<InOutPoint> it, int dx, int dy) {
123 (*it).m_dx = dx;
124 (*it).m_dy = dy;
125 }
126
127 void setInCoord(ListIterator<InOutPoint> it, int dx, int dy) {
128 (*it).m_dx = dx;
129 (*it).m_dy = dy;
130 }
131
132 void setOutDx(ListIterator<InOutPoint> it, int dx) { (*it).m_dx = dx; }
133
135
137 m_out[v].popBack();
139 }
140
141 // belongs v to a chain (= at most to non-marked incoming edges
142 bool isChain(node v) const {
143 int i = 0;
144 for (const InOutPoint& iop : m_in[v]) {
145 if (!marked(iop.m_adj)) {
146 ++i;
147 }
148 }
149 return i <= 2;
150 }
151
152 // width of the left-/right side of an in-/outpoint list
153 int outLeft(node v) const { return (m_out[v].empty()) ? 0 : (-m_out[v].front().m_dx); }
154
155 int outRight(node v) const { return (m_out[v].empty()) ? 0 : (m_out[v].back().m_dx); }
156
157 int inLeft(node v) const { return (m_in[v].empty()) ? 0 : (-m_in[v].front().m_dx); }
158
159 int inRight(node v) const { return (m_in[v].empty()) ? 0 : (m_in[v].back().m_dx); }
160
161 int maxLeft(node v) const { return max(inLeft(v), outLeft(v)); }
162
163 int maxRight(node v) const { return max(inRight(v), outRight(v)); }
164
165 int maxPlusLeft(node v) const {
166 return (in(v) >= 3) ? max(inLeft(v) + 1, outLeft(v)) : maxLeft(v);
167 }
168
169 int maxPlusRight(node v) const {
170 return (in(v) >= 3) ? max(inRight(v) + 1, outRight(v)) : maxRight(v);
171 }
172
174
175 void numDeg1(node v, int& xl, int& xr, bool doubleCount) const;
176
179
182
183
185
186
187private:
191
194};
195
196}
Declaration of a base class for planar representations of graphs and cluster graphs.
Class for adjacency list elements.
Definition Graph_d.h:79
node theNode() const
Returns the node whose adjacency list contains this element.
Definition Graph_d.h:103
Dynamic arrays indexed with adjacency entries.
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
Definition ArrayBuffer.h:56
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:521
Representation of in- and outpoint lists.
Definition IOPoints.h:57
int maxLeft(node v) const
Definition IOPoints.h:161
ListConstIterator< InOutPoint > prevRealOut(ListConstIterator< InOutPoint > it) const
Definition IOPoints.h:101
ListConstIterator< InOutPoint > searchRealBackward(ListConstIterator< InOutPoint > it) const
ListConstIterator< InOutPoint > searchRealForward(ListConstIterator< InOutPoint > it) const
int in(node v) const
Definition IOPoints.h:69
void switchEndOut(node v)
ListConstIterator< InOutPoint > lastRealOut(node v) const
Definition IOPoints.h:93
const InOutPoint * pointOf(adjEntry adj) const
Definition IOPoints.h:81
InOutPoint middleNeighbor(node z1) const
bool marked(node v)
Definition IOPoints.h:86
int maxPlusLeft(node v) const
Definition IOPoints.h:165
void switchBeginOut(node v)
void appendInpoint(adjEntry adj)
Definition IOPoints.h:106
const List< InOutPoint > & inpoints(node v) const
Definition IOPoints.h:72
AdjEntryArray< bool > m_mark
Definition IOPoints.h:189
void setInCoord(ListIterator< InOutPoint > it, int dx, int dy)
Definition IOPoints.h:127
NodeArray< int > m_height
Definition IOPoints.h:184
List< InOutPoint > & outpoints(node v)
Definition IOPoints.h:78
void pushInpoint(adjEntry adj)
Definition IOPoints.h:116
void restoreDeg1Nodes(PlanRep &PG, ArrayBuffer< PlanRep::Deg1RestoreInfo > &S)
const List< InOutPoint > & outpoints(node v) const
Definition IOPoints.h:76
AdjEntryArray< InOutPoint * > m_pointOf
Definition IOPoints.h:190
ListConstIterator< InOutPoint > firstRealOut(node v) const
Definition IOPoints.h:89
int inLeft(node v) const
Definition IOPoints.h:157
int maxPlusRight(node v) const
Definition IOPoints.h:169
int outLeft(node v) const
Definition IOPoints.h:153
void setOutCoord(ListIterator< InOutPoint > it, int dx, int dy)
Definition IOPoints.h:122
int inRight(node v) const
Definition IOPoints.h:159
void setOutDx(ListIterator< InOutPoint > it, int dx)
Definition IOPoints.h:132
void changeEdge(node v, adjEntry adj_new)
Definition IOPoints.h:136
int out(node v) const
Definition IOPoints.h:67
NodeArray< List< InOutPoint > > m_out
Definition IOPoints.h:188
NodeArray< List< InOutPoint > > m_in
Definition IOPoints.h:188
IOPoints(const Graph &G)
Definition IOPoints.h:61
adjEntry switchEndIn(node v)
bool isChain(node v) const
Definition IOPoints.h:142
NodeArray< int > m_depth
Definition IOPoints.h:184
int maxRight(node v) const
Definition IOPoints.h:163
ListConstIterator< InOutPoint > nextRealOut(ListConstIterator< InOutPoint > it) const
Definition IOPoints.h:97
List< InOutPoint > & inpoints(node v)
Definition IOPoints.h:74
adjEntry switchBeginIn(node v)
bool marked(adjEntry adj) const
Definition IOPoints.h:84
int outRight(node v) const
Definition IOPoints.h:155
void appendOutpoint(adjEntry adj)
Definition IOPoints.h:111
void numDeg1(node v, int &xl, int &xr, bool doubleCount) const
Doubly linked lists (maintaining the length of the list).
Definition List.h:1435
Encapsulates a pointer to a list element.
Definition List.h:103
ListIteratorBase< E, isConst, isReverse > succ() const
Returns successor iterator.
Definition List.h:158
ListIteratorBase< E, isConst, isReverse > pred() const
Returns predecessor iterator.
Definition List.h:163
Dynamic arrays indexed with nodes.
Definition NodeArray.h:125
Class for the representation of nodes.
Definition Graph_d.h:177
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
Definition Graph_d.h:223
int outdeg() const
Returns the outdegree of the node.
Definition Graph_d.h:217
Planarized representations (of a connected component) of a graph.
Definition PlanRep.h:57
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.
Representation of an in- or outpoint.
Definition IOPoints.h:41
InOutPoint(adjEntry adj)
Definition IOPoints.h:50
adjEntry m_adj
Definition IOPoints.h:43