Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

NodeInfo.h
Go to the documentation of this file.
1 
37 #pragma once
38 
40 #include <ogdf/basic/GridLayout.h>
44 #include <ogdf/planarity/PlanRep.h>
45 
46 #include <array>
47 
48 namespace ogdf {
49 namespace edge_router {
50 
52 public:
53  //standard constr.
54  NodeInfo() { init(); }
55 
56  void init() {
57  for (int i = 0; i < 4; i++) {
58  for (int j = 0; j < 4; j++) {
59  m_nbe[i][j] = 0;
60  m_delta[i][j] = 0;
61  m_eps[i][j] = 0;
62  m_routable[i][j] = 0;
63  m_flips[i][j] = 0;
64  }
65  num_s_edges[i] = 0;
66  m_gen_pos[i] = -1;
67  m_nbf[i] = 0;
68  m_rc[i] = 0;
69  m_coord[i] = 0;
70  m_ccoord[i] = 0;
71  }
72  lu = ll = ru = rl = tl = tr = bl = br = 0;
73  cage_x_size = cage_y_size = box_x_size = box_y_size = 0;
74  m_vdegree = 0;
75  m_firstAdj = m_adj = nullptr;
76  }
77 
78  //Constructor, adj holds entry for inner face edge
81  : m_adj(adj) {
82  init();
83  get_data(H, L, v, rc, nw, nh);
84  }
85 
87  int coord(OrthoDir bs) const { return m_coord[static_cast<int>(bs)]; }
88 
90  int cageCoord(OrthoDir bs) const { return m_ccoord[static_cast<int>(bs)]; }
91 
92  //return distance between Node and Cage coord
94  int result;
95  int bsi = static_cast<int>(bs);
96  switch (bs) {
97  case OrthoDir::South:
98  case OrthoDir::East:
99  result = m_ccoord[bsi] - m_coord[bsi];
100  break;
101  case OrthoDir::North:
102  case OrthoDir::West:
103  result = m_coord[bsi] - m_ccoord[bsi];
104  break;
105  default:
106  std::cout << "unknown direction in coordDistance" << std::flush;
108  }
109  OGDF_ASSERT(result >= 0);
110  return result;
111  }
112 
113  // original box sizes, fake
114  int node_xsize() const { return box_x_size; }
115 
116  int node_ysize() const { return box_y_size; }
117 
118  int nodeSize(OrthoDir od) const {
119  return (static_cast<int>(od) % 2 == 0) ? box_y_size : box_x_size;
120  }
121 
122  int cageSize(OrthoDir od) const {
123  return (static_cast<int>(od) % 2 == 0) ? cage_y_size : cage_x_size;
124  }
125 
127  int rc(OrthoDir od) const { return m_rc[static_cast<int>(od)]; }
128 
129  List<edge>& inList(OrthoDir bs) { return in_edges[static_cast<int>(bs)]; }
130 
131  List<bool>& inPoint(OrthoDir bs) { return point_in[static_cast<int>(bs)]; }
132 
133  //these values are computed dependant on the nodes placement
134  // position of first and last unbend edge on every side
135  int l_upper_unbend() { return lu; }
136 
137  int l_lower_unbend() { return ll; }
138 
139  int r_upper_unbend() { return ru; }
140 
141  int r_lower_unbend() { return rl; }
142 
143  int t_left_unbend() { return tl; }
144 
145  int t_right_unbend() { return tr; }
146 
147  int b_left_unbend() { return bl; }
148 
149  int b_right_unbend() { return br; }
150 
151  //object separation distances
152  //if (no) generalization enters..., side/gener. dependant paper delta values
153  //distance at side mainside, left/right from existing generalization to side neighbour
154  int delta(OrthoDir mainside, OrthoDir neighbour) const {
155  return m_delta[static_cast<int>(mainside)][static_cast<int>(neighbour)];
156  }
157 
158  //paper epsilon
159  int eps(OrthoDir mainside, OrthoDir neighbour) const {
160  return m_eps[static_cast<int>(mainside)][static_cast<int>(neighbour)];
161  }
162 
163  //cardinality of the set of edges that will bend, bside side to the side bneighbour
164  int num_bend_edges(OrthoDir s1, OrthoDir sneighbour) {
165  return m_nbe[static_cast<int>(s1)][static_cast<int>(sneighbour)];
166  }
167 
168  //number of edges flipped from s1 to s2 to save one bend
169  int& flips(OrthoDir s1, OrthoDir s2) {
170  return m_flips[static_cast<int>(s1)][static_cast<int>(s2)];
171  }
172 
173  // number of edges routed bendfree
174  int num_bend_free(OrthoDir s) const { return m_nbf[static_cast<int>(s)]; }
175 
176  void num_bend_free_increment(OrthoDir s) { ++m_nbf[static_cast<int>(s)]; }
177 
178  int num_edges(OrthoDir od) const {
179  return num_s_edges[static_cast<int>(od)]; //return number of edges at side od
180  }
181 
182  //position of gen. edges in edge lists for every side, starting with 1
183  int gen_pos(OrthoDir od) const { return m_gen_pos[static_cast<int>(od)]; }
184 
185  bool has_gen(OrthoDir od) { return m_gen_pos[static_cast<int>(od)] > -1; }
186 
187  bool is_in_edge(OrthoDir od, int pos) {
188  ListConstIterator<bool> b_it = point_in[static_cast<int>(od)].get(pos);
189  OGDF_ASSERT(b_it.valid());
190  return *b_it;
191  }
192 
193  void set_coord(OrthoDir bs, int co) { m_coord[static_cast<int>(bs)] = co; }
194 
195  void setCageCoord(OrthoDir bs, int co) { m_ccoord[static_cast<int>(bs)] = co; }
196 
197  //delta values, due to placement problems, cut to box_size / 2
198  void set_delta(OrthoDir bside, OrthoDir bneighbour, int dval) {
199  int bsidei = static_cast<int>(bside);
200  int bneighbouri = static_cast<int>(bneighbour);
201  switch (bside) {
202  case OrthoDir::North:
203  case OrthoDir::South:
204  if (dval > box_y_size) {
205  dval = int(floor(((double)box_y_size / 2))) - m_eps[bsidei][bneighbouri];
206  }
207  break;
208  case OrthoDir::East:
209  case OrthoDir::West:
210  if (dval > box_x_size) {
211  dval = int(floor(((double)box_x_size / 2))) - m_eps[bsidei][bneighbouri];
212  }
213  break;
214  default:
215  OGDF_ASSERT(false);
216  }
217  m_delta[bsidei][bneighbouri] = dval;
218  }
219 
220  void set_eps(OrthoDir mainside, OrthoDir neighbour, int dval) {
221  m_eps[static_cast<int>(mainside)][static_cast<int>(neighbour)] = dval;
222  }
223 
224 #if 0
225  void set_num_bend_edges(box_side bs1, box_side bs2, int num) {nbe[bs1][bs2] = num;}
227 #endif
228 
230  void set_gen_pos(OrthoDir od, int pos) {
231  m_gen_pos[static_cast<int>(od)] = pos; //odir: N 0, E 1
232  }
233 
234  void set_num_edges(OrthoDir od, int num) {
235  num_s_edges[static_cast<int>(od)] = num; //odir: N 0, E 1, check correct od parameter?
236  }
237 
240  cage_x_size = m_ccoord[static_cast<int>(OrthoDir::South)]
241  - m_ccoord[static_cast<int>(OrthoDir::North)];
242  cage_y_size = m_ccoord[static_cast<int>(OrthoDir::East)]
243  - m_ccoord[static_cast<int>(OrthoDir::West)];
244  }
245 
246  //set the unbend edges after (in) placement step
247  void set_l_upper(int d) { lu = d; }
248 
249  void set_l_lower(int d) { ll = d; }
250 
251  void set_r_upper(int d) { ru = d; }
252 
253  void set_r_lower(int d) { rl = d; }
254 
255  void set_t_left(int d) { tl = d; }
256 
257  void set_t_right(int d) { tr = d; }
258 
259  void set_b_left(int d) { bl = d; }
260 
261  void set_b_right(int d) { br = d; }
262 
263  //paper set E_s1_s2
264  void inc_E_hook(OrthoDir s_from, OrthoDir s_to, int num = 1) {
265  int s_from_i = static_cast<int>(s_from);
266  int s_to_i = static_cast<int>(s_to);
267  m_routable[s_from_i][s_to_i] += num;
268  m_nbe[s_from_i][s_to_i] += num;
269  }
270 
271  void inc_E(OrthoDir s_from, OrthoDir s_to, int num = 1) {
272  m_nbe[static_cast<int>(s_from)][static_cast<int>(s_to)] += num;
273  }
274 
275  //read the information for node v from attributed graph/planrep
276  //(needs positions ...)
277  void get_data(OrthoRep& O, GridLayout& L, node v, RoutingChannel<int>& rc, NodeArray<int>& nw,
278  NodeArray<int>& nh); //check input parameter
279 
280  // card. of paper E^_s1,s2
281  int num_routable(OrthoDir s_from, OrthoDir s_to) const {
282  return m_routable[static_cast<int>(s_from)][static_cast<int>(s_to)];
283  }
284 
285  int vDegree() { return m_vdegree; }
286 
287  adjEntry& firstAdj() { return m_firstAdj; }
288 
289  friend std::ostream& operator<<(std::ostream& O, const NodeInfo& inf);
290 
291 private:
292  std::array<int, 4> m_rc;
293  std::array<int, 4> m_coord; //coordinates of box segments, x for ls_left/right, y for s_top/bottom
294  std::array<int, 4> m_ccoord; //coordinates of expanded cage segments, -"-
295  int cage_x_size, cage_y_size, //cage size
296  box_x_size, box_y_size; //box size
297  int lu, ll, ru, rl, tl, tr, bl, br; //first/last unbend edge on all sides
298  //most of the following are only [4][2] but use 44 for users conv
299  int m_delta[4][4]; //sepa. distance (paper delta)
300  int m_eps[4][4]; //corner separation distance (paper epsilon)
301  std::array<int, 4> m_gen_pos; //pos num of generaliz. edge in adj lists
302  std::array<int, 4> num_s_edges; //number of edges at sides 0..3=N..W
303  int m_routable[4][4]; //number of reroutable edges, paper E^_s1,s2, got to be initialized after box placement
304  int m_flips[4][4]; //real number of flipped edges
305  int m_nbe[4][4]; //paper E_s1,s2
306  std::array<int, 4> m_nbf; //number of bendfree edges per side
307  adjEntry m_firstAdj; //adjEntry of first encountered outgoing edge, note: this is a copy
308 
309  std::array<List<edge>, 4> in_edges; //inedges on each side will be replaced by dynamic ops
310  //preliminary bugfix of in/out dilemma
311  std::array<List<bool>, 4> point_in; //save in/out info
312  adjEntry m_adj; //entry of inner cage face
313  //degree of expanded vertex
315 };
316 
317 std::ostream& operator<<(std::ostream& O, const NodeInfo& inf);
318 
319 }
320 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::edge_router::NodeInfo::node_xsize
int node_xsize() const
Definition: NodeInfo.h:114
ogdf::edge_router::NodeInfo::set_num_edges
void set_num_edges(OrthoDir od, int num)
Definition: NodeInfo.h:234
ogdf::edge_router::NodeInfo::t_left_unbend
int t_left_unbend()
Definition: NodeInfo.h:143
ogdf::edge_router::NodeInfo::flips
int & flips(OrthoDir s1, OrthoDir s2)
Definition: NodeInfo.h:169
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:54
ogdf::edge_router::NodeInfo
Definition: NodeInfo.h:51
ogdf::edge_router::NodeInfo::m_firstAdj
adjEntry m_firstAdj
Definition: NodeInfo.h:307
ogdf::edge_router::NodeInfo::m_rc
std::array< int, 4 > m_rc
Definition: NodeInfo.h:292
ogdf::edge_router::NodeInfo::vDegree
int vDegree()
Definition: NodeInfo.h:285
ogdf::edge_router::NodeInfo::l_upper_unbend
int l_upper_unbend()
Definition: NodeInfo.h:135
ogdf::edge_router::NodeInfo::set_l_upper
void set_l_upper(int d)
Definition: NodeInfo.h:247
ogdf::edge_router::NodeInfo::set_coord
void set_coord(OrthoDir bs, int co)
Definition: NodeInfo.h:193
ogdf::OrthoDir
OrthoDir
Definition: OrthoRep.h:50
ogdf::edge_router::NodeInfo::m_coord
std::array< int, 4 > m_coord
Definition: NodeInfo.h:293
ogdf::edge_router::NodeInfo::b_right_unbend
int b_right_unbend()
Definition: NodeInfo.h:149
ogdf::OrthoDir::West
@ West
ogdf::edge_router::NodeInfo::setCageCoord
void setCageCoord(OrthoDir bs, int co)
Definition: NodeInfo.h:195
ogdf::edge_router::NodeInfo::m_gen_pos
std::array< int, 4 > m_gen_pos
Definition: NodeInfo.h:301
ogdf::edge_router::NodeInfo::coord
int coord(OrthoDir bs) const
Returns nodeboxside coordinates (real size)
Definition: NodeInfo.h:87
ogdf::edge_router::NodeInfo::rc
int rc(OrthoDir od) const
Returns routing channel size.
Definition: NodeInfo.h:127
ogdf::edge_router::NodeInfo::coordDistance
int coordDistance(OrthoDir bs)
Definition: NodeInfo.h:93
ogdf::edge_router::NodeInfo::set_r_lower
void set_r_lower(int d)
Definition: NodeInfo.h:253
ogdf::edge_router::NodeInfo::inPoint
List< bool > & inPoint(OrthoDir bs)
Definition: NodeInfo.h:131
ogdf::edge_router::NodeInfo::cageSize
int cageSize(OrthoDir od) const
Definition: NodeInfo.h:122
ogdf::edge_router::NodeInfo::in_edges
std::array< List< edge >, 4 > in_edges
Definition: NodeInfo.h:309
ogdf::edge_router::NodeInfo::point_in
std::array< List< bool >, 4 > point_in
Definition: NodeInfo.h:311
ogdf::OrthoDir::South
@ South
ogdf::edge_router::NodeInfo::inc_E_hook
void inc_E_hook(OrthoDir s_from, OrthoDir s_to, int num=1)
Definition: NodeInfo.h:264
ogdf::ListIteratorBase::valid
bool valid() const
Returns true iff the iterator points to an element.
Definition: List.h:143
ogdf::edge_router::NodeInfo::num_bend_edges
int num_bend_edges(OrthoDir s1, OrthoDir sneighbour)
Definition: NodeInfo.h:164
ogdf::edge_router::NodeInfo::compute_cage_size
void compute_cage_size()
compute the size of the cage face and the node box
Definition: NodeInfo.h:239
ogdf::edge_router::NodeInfo::has_gen
bool has_gen(OrthoDir od)
Definition: NodeInfo.h:185
ogdf::edge_router::NodeInfo::b_left_unbend
int b_left_unbend()
Definition: NodeInfo.h:147
ogdf::edge_router::NodeInfo::set_delta
void set_delta(OrthoDir bside, OrthoDir bneighbour, int dval)
Definition: NodeInfo.h:198
ogdf::edge_router::NodeInfo::m_vdegree
int m_vdegree
Definition: NodeInfo.h:314
PlanRep.h
Declaration of a base class for planar representations of graphs and cluster graphs.
ogdf::edge_router::NodeInfo::set_b_right
void set_b_right(int d)
Definition: NodeInfo.h:261
ogdf::edge_router::NodeInfo::is_in_edge
bool is_in_edge(OrthoDir od, int pos)
Definition: NodeInfo.h:187
ogdf::AdjElement
Class for adjacency list elements.
Definition: Graph_d.h:135
ogdf::AlgorithmFailureException
Exception thrown when an algorithm realizes an internal bug that prevents it from continuing.
Definition: exceptions.h:243
ogdf::edge_router::NodeInfo::tr
int tr
Definition: NodeInfo.h:297
ogdf::edge_router::NodeInfo::num_edges
int num_edges(OrthoDir od) const
Definition: NodeInfo.h:178
ogdf::edge_router::NodeInfo::cage_y_size
int cage_y_size
Definition: NodeInfo.h:295
ogdf::edge_router::NodeInfo::num_routable
int num_routable(OrthoDir s_from, OrthoDir s_to) const
Definition: NodeInfo.h:281
ogdf::edge_router::NodeInfo::NodeInfo
NodeInfo(OrthoRep &H, GridLayout &L, node v, adjEntry adj, RoutingChannel< int > &rc, NodeArray< int > &nw, NodeArray< int > &nh)
Definition: NodeInfo.h:79
ogdf::edge_router::NodeInfo::m_adj
adjEntry m_adj
Definition: NodeInfo.h:312
ogdf::edge_router::NodeInfo::l_lower_unbend
int l_lower_unbend()
Definition: NodeInfo.h:137
OrthoRep.h
Declaration of orthogonal representation of planar graphs.
OGDF_THROW
#define OGDF_THROW(CLASS)
Replacement for throw.
Definition: exceptions.h:70
ogdf::OrthoRep
Orthogonal representation of an embedded graph.
Definition: OrthoRep.h:219
ogdf::edge_router::NodeInfo::inc_E
void inc_E(OrthoDir s_from, OrthoDir s_to, int num=1)
Definition: NodeInfo.h:271
ogdf::edge_router::NodeInfo::firstAdj
adjEntry & firstAdj()
Definition: NodeInfo.h:287
MinimumEdgeDistances.h
Declaration of class MinimumEdgeDistances which maintains minimum distances between attached edges at...
ogdf::edge_router::NodeInfo::num_s_edges
std::array< int, 4 > num_s_edges
Definition: NodeInfo.h:302
ogdf::edge_router::NodeInfo::set_r_upper
void set_r_upper(int d)
Definition: NodeInfo.h:251
ogdf::edge_router::NodeInfo::set_l_lower
void set_l_lower(int d)
Definition: NodeInfo.h:249
ogdf::edge_router::NodeInfo::t_right_unbend
int t_right_unbend()
Definition: NodeInfo.h:145
ogdf::edge_router::NodeInfo::init
void init()
Definition: NodeInfo.h:56
ogdf::List< edge >
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:651
ogdf::edge_router::NodeInfo::r_lower_unbend
int r_lower_unbend()
Definition: NodeInfo.h:141
ogdf::edge_router::NodeInfo::set_t_right
void set_t_right(int d)
Definition: NodeInfo.h:257
ogdf::graphics::init
void init()
Definition: graphics.h:446
ogdf::edge_router::NodeInfo::node_ysize
int node_ysize() const
Definition: NodeInfo.h:116
ogdf::edge_router::NodeInfo::r_upper_unbend
int r_upper_unbend()
Definition: NodeInfo.h:139
ogdf::edge_router::NodeInfo::inList
List< edge > & inList(OrthoDir bs)
Definition: NodeInfo.h:129
ogdf::edge_router::NodeInfo::NodeInfo
NodeInfo()
Definition: NodeInfo.h:54
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::edge_router::NodeInfo::num_bend_free
int num_bend_free(OrthoDir s) const
Definition: NodeInfo.h:174
ogdf::edge_router::NodeInfo::set_t_left
void set_t_left(int d)
Definition: NodeInfo.h:255
AdjEntryArray.h
Declaration and implementation of AdjEntryArray class.
ogdf::OrthoDir::East
@ East
ogdf::edge_router::NodeInfo::gen_pos
int gen_pos(OrthoDir od) const
Definition: NodeInfo.h:183
ogdf::edge_router::NodeInfo::delta
int delta(OrthoDir mainside, OrthoDir neighbour) const
Definition: NodeInfo.h:154
ogdf::edge_router::NodeInfo::m_ccoord
std::array< int, 4 > m_ccoord
Definition: NodeInfo.h:294
ogdf::edge_router::NodeInfo::m_nbf
std::array< int, 4 > m_nbf
Definition: NodeInfo.h:306
ogdf::GridLayout
Representation of a graph's grid layout.
Definition: GridLayout.h:46
ogdf::edge_router::NodeInfo::cageCoord
int cageCoord(OrthoDir bs) const
Returns nodecageside coordinates (expanded size)
Definition: NodeInfo.h:90
ogdf::OrthoDir::North
@ North
ogdf::ListIteratorBase
Encapsulates a pointer to a list element.
Definition: List.h:46
ogdf::edge_router::NodeInfo::set_eps
void set_eps(OrthoDir mainside, OrthoDir neighbour, int dval)
Definition: NodeInfo.h:220
RoutingChannel.h
Declaration of class RoutingChannel which maintains required size of routing channels and separation,...
ogdf::edge_router::NodeInfo::set_gen_pos
void set_gen_pos(OrthoDir od, int pos)
set position of generalization on each side
Definition: NodeInfo.h:230
ogdf::edge_router::operator<<
std::ostream & operator<<(std::ostream &O, const NodeInfo &inf)
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
GridLayout.h
Declaration of class GridLayout.
ogdf::edge_router::NodeInfo::box_y_size
int box_y_size
Definition: NodeInfo.h:296
ogdf::edge_router::NodeInfo::num_bend_free_increment
void num_bend_free_increment(OrthoDir s)
Definition: NodeInfo.h:176
ogdf::edge_router::NodeInfo::set_b_left
void set_b_left(int d)
Definition: NodeInfo.h:259
ogdf::edge_router::NodeInfo::eps
int eps(OrthoDir mainside, OrthoDir neighbour) const
Definition: NodeInfo.h:159
ogdf::edge_router::NodeInfo::nodeSize
int nodeSize(OrthoDir od) const
Definition: NodeInfo.h:118
ogdf::RoutingChannel< int >