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#include <ogdf/basic/Graph.h>
37#include <ogdf/basic/List.h>
38#include <ogdf/basic/basic.h>
40
41#include <algorithm>
42
43namespace ogdf {
44
45
47struct InOutPoint {
48 int m_dx, m_dy;
50
52 m_dx = m_dy = 0;
53 m_adj = nullptr;
54 }
55
56 explicit InOutPoint(adjEntry adj) {
57 m_adj = adj;
58 m_dx = m_dy = 0;
59 }
60};
61
63class IOPoints {
64public:
66
67 explicit IOPoints(const Graph& G)
68 : m_depth(G, 0), m_height(G, 0), m_in(G), m_out(G), m_mark(G, false), m_pointOf(G, nullptr) { }
69
71
72 // length of in- or outpoint list
73 int out(node v) const { return m_out[v].size(); }
74
75 int in(node v) const { return m_in[v].size(); }
76
77 // getting a const-reference to in- or outpoint list
78 const List<InOutPoint>& inpoints(node v) const { return m_in[v]; }
79
81
82 const List<InOutPoint>& outpoints(node v) const { return m_out[v]; }
83
85
86 // getting the in-/outpoint belonging to an adjacency entry
87 const InOutPoint* pointOf(adjEntry adj) const { return m_pointOf[adj]; }
88
89 // marking adjacency entries
90 bool marked(adjEntry adj) const { return m_mark[adj]; }
91
92 bool marked(node v) { return v->outdeg() == 1 && marked(v->firstAdj()); }
93
94 // finding outpoints belonging to non-marked edges
98
100 return searchRealBackward(m_out[v].rbegin());
101 }
102
106
110
111 // building in-/outpoint lists
113 node v = adj->theNode();
114 m_pointOf[adj] = &(*m_in[v].pushBack(InOutPoint(adj)));
115 }
116
118 node v = adj->theNode();
119 m_pointOf[adj] = &(*m_out[v].pushBack(InOutPoint(adj)));
120 }
121
123 node v = adj->theNode();
124 m_pointOf[adj] = &(*m_in[v].pushFront(InOutPoint(adj)));
125 }
126
127 // setting relative coordinates
128 void setOutCoord(ListIterator<InOutPoint> it, int dx, int dy) {
129 (*it).m_dx = dx;
130 (*it).m_dy = dy;
131 }
132
133 void setInCoord(ListIterator<InOutPoint> it, int dx, int dy) {
134 (*it).m_dx = dx;
135 (*it).m_dy = dy;
136 }
137
138 void setOutDx(ListIterator<InOutPoint> it, int dx) { (*it).m_dx = dx; }
139
141
142 void changeEdge(node v, adjEntry adj_new) {
143 m_out[v].popBack();
144 appendInpoint(adj_new);
145 }
146
147 // belongs v to a chain (= at most to non-marked incoming edges
148 bool isChain(node v) const {
149 int i = 0;
150 for (const InOutPoint& iop : m_in[v]) {
151 if (!marked(iop.m_adj)) {
152 ++i;
153 }
154 }
155 return i <= 2;
156 }
157
158 // width of the left-/right side of an in-/outpoint list
159 int outLeft(node v) const { return (m_out[v].empty()) ? 0 : (-m_out[v].front().m_dx); }
160
161 int outRight(node v) const { return (m_out[v].empty()) ? 0 : (m_out[v].back().m_dx); }
162
163 int inLeft(node v) const { return (m_in[v].empty()) ? 0 : (-m_in[v].front().m_dx); }
164
165 int inRight(node v) const { return (m_in[v].empty()) ? 0 : (m_in[v].back().m_dx); }
166
167 int maxLeft(node v) const { return max(inLeft(v), outLeft(v)); }
168
169 int maxRight(node v) const { return max(inRight(v), outRight(v)); }
170
171 int maxPlusLeft(node v) const {
172 return (in(v) >= 3) ? max(inLeft(v) + 1, outLeft(v)) : maxLeft(v);
173 }
174
175 int maxPlusRight(node v) const {
176 return (in(v) >= 3) ? max(inRight(v) + 1, outRight(v)) : maxRight(v);
177 }
178
180
181 void numDeg1(node v, int& xl, int& xr, bool doubleCount) const;
182
185
188
189
191
192
193private:
197
200};
201
202}
Declaration and implementation of ArrayBuffer class.
Includes declaration of graph class.
Declaration of doubly linked lists and iterators.
Declaration of a base class for planar representations of graphs and cluster graphs.
Basic declarations, included by all source files.
Class for adjacency list elements.
Definition Graph_d.h:143
node theNode() const
Returns the node whose adjacency list contains this element.
Definition Graph_d.h:167
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
Definition ArrayBuffer.h:64
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
Representation of in- and outpoint lists.
Definition IOPoints.h:63
int maxLeft(node v) const
Definition IOPoints.h:167
ListConstIterator< InOutPoint > prevRealOut(ListConstIterator< InOutPoint > it) const
Definition IOPoints.h:107
ListConstIterator< InOutPoint > searchRealBackward(ListConstIterator< InOutPoint > it) const
ListConstIterator< InOutPoint > searchRealForward(ListConstIterator< InOutPoint > it) const
int in(node v) const
Definition IOPoints.h:75
void switchEndOut(node v)
ListConstIterator< InOutPoint > lastRealOut(node v) const
Definition IOPoints.h:99
const InOutPoint * pointOf(adjEntry adj) const
Definition IOPoints.h:87
InOutPoint middleNeighbor(node z1) const
bool marked(node v)
Definition IOPoints.h:92
int maxPlusLeft(node v) const
Definition IOPoints.h:171
void switchBeginOut(node v)
void appendInpoint(adjEntry adj)
Definition IOPoints.h:112
const List< InOutPoint > & inpoints(node v) const
Definition IOPoints.h:78
AdjEntryArray< bool > m_mark
Definition IOPoints.h:195
void setInCoord(ListIterator< InOutPoint > it, int dx, int dy)
Definition IOPoints.h:133
NodeArray< int > m_height
Definition IOPoints.h:190
List< InOutPoint > & outpoints(node v)
Definition IOPoints.h:84
void pushInpoint(adjEntry adj)
Definition IOPoints.h:122
void restoreDeg1Nodes(PlanRep &PG, ArrayBuffer< PlanRep::Deg1RestoreInfo > &S)
const List< InOutPoint > & outpoints(node v) const
Definition IOPoints.h:82
AdjEntryArray< InOutPoint * > m_pointOf
Definition IOPoints.h:196
ListConstIterator< InOutPoint > firstRealOut(node v) const
Definition IOPoints.h:95
int inLeft(node v) const
Definition IOPoints.h:163
int maxPlusRight(node v) const
Definition IOPoints.h:175
int outLeft(node v) const
Definition IOPoints.h:159
void setOutCoord(ListIterator< InOutPoint > it, int dx, int dy)
Definition IOPoints.h:128
int inRight(node v) const
Definition IOPoints.h:165
void setOutDx(ListIterator< InOutPoint > it, int dx)
Definition IOPoints.h:138
void changeEdge(node v, adjEntry adj_new)
Definition IOPoints.h:142
int out(node v) const
Definition IOPoints.h:73
NodeArray< List< InOutPoint > > m_out
Definition IOPoints.h:194
NodeArray< List< InOutPoint > > m_in
Definition IOPoints.h:194
IOPoints(const Graph &G)
Definition IOPoints.h:67
adjEntry switchEndIn(node v)
bool isChain(node v) const
Definition IOPoints.h:148
NodeArray< int > m_depth
Definition IOPoints.h:190
int maxRight(node v) const
Definition IOPoints.h:169
ListConstIterator< InOutPoint > nextRealOut(ListConstIterator< InOutPoint > it) const
Definition IOPoints.h:103
List< InOutPoint > & inpoints(node v)
Definition IOPoints.h:80
adjEntry switchBeginIn(node v)
bool marked(adjEntry adj) const
Definition IOPoints.h:90
int outRight(node v) const
Definition IOPoints.h:161
void appendOutpoint(adjEntry adj)
Definition IOPoints.h:117
void numDeg1(node v, int &xl, int &xr, bool doubleCount) const
Doubly linked lists (maintaining the length of the list).
Definition List.h:1451
Encapsulates a pointer to a list element.
Definition List.h:113
ListIteratorBase< E, isConst, isReverse > succ() const
Returns successor iterator.
Definition List.h:174
ListIteratorBase< E, isConst, isReverse > pred() const
Returns predecessor iterator.
Definition List.h:179
Class for the representation of nodes.
Definition Graph_d.h:241
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
Definition Graph_d.h:287
int outdeg() const
Returns the outdegree of the node.
Definition Graph_d.h:281
Planarized representations (of a connected component) of a graph.
Definition PlanRep.h:68
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition Graph_d.h:659
The namespace for all OGDF objects.
HypergraphRegistry< HypernodeElement >::iterator begin(const HypergraphRegistry< HypernodeElement > &self)
Representation of an in- or outpoint.
Definition IOPoints.h:47
InOutPoint(adjEntry adj)
Definition IOPoints.h:56
adjEntry m_adj
Definition IOPoints.h:49