Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

RoutingChannel.h
Go to the documentation of this file.
1 
33 #pragma once
34 
35 #include <ogdf/basic/Graph.h>
36 #include <ogdf/basic/GraphList.h>
37 #include <ogdf/basic/basic.h>
39 
40 #include <algorithm>
41 
42 namespace ogdf {
43 
46 template<class ATYPE>
48 public:
49  // constructor
50  RoutingChannel(const Graph& G, ATYPE sep, double cOver)
51  : m_channel(G), m_separation(sep), m_cOverhang(cOver) { }
52 
53  // size of routing channel of side dir of node v
54  const ATYPE& operator()(node v, OrthoDir dir) const {
55  return m_channel[v].rc[static_cast<int>(dir)];
56  }
57 
58  ATYPE& operator()(node v, OrthoDir dir) { return m_channel[v].rc[static_cast<int>(dir)]; }
59 
60  // returns separation (minimum distance between vertices/edges)
61  ATYPE separation() const { return m_separation; }
62 
63  // returns cOverhang (such that overhang = separation * cOverhang)
64  double cOverhang() const { return m_cOverhang; }
65 
66  // returns overhang (distance between vertex corners and edges)
67  ATYPE overhang() const { return ATYPE(m_cOverhang * m_separation); }
68 
69  void computeRoutingChannels(const OrthoRep& OR, bool align = false) {
70  const Graph& G = OR;
71 
72  for (node v : G.nodes) {
73  const OrthoRep::VertexInfoUML* pInfo = OR.cageInfo(v);
74 
75  if (pInfo) {
76  const OrthoRep::SideInfoUML& sNorth =
77  pInfo->m_side[static_cast<int>(OrthoDir::North)];
78  const OrthoRep::SideInfoUML& sSouth =
79  pInfo->m_side[static_cast<int>(OrthoDir::South)];
80  const OrthoRep::SideInfoUML& sWest = pInfo->m_side[static_cast<int>(OrthoDir::West)];
81  const OrthoRep::SideInfoUML& sEast = pInfo->m_side[static_cast<int>(OrthoDir::East)];
82 
83  (*this)(v, OrthoDir::North) = computeRoutingChannel(sNorth, sSouth, align);
84  (*this)(v, OrthoDir::South) = computeRoutingChannel(sSouth, sNorth, align);
85  (*this)(v, OrthoDir::West) = computeRoutingChannel(sWest, sEast, align);
86  (*this)(v, OrthoDir::East) = computeRoutingChannel(sEast, sWest, align);
87  }
88  }
89  }
90 
91 private:
92  // computes required size of routing channel at side si with opposite side siOpp
94  bool align = false) {
95  if (si.m_adjGen == nullptr) {
96  int k = si.m_nAttached[0];
97  if (k == 0 || ((k == 1 && siOpp.totalAttached() == 0) && !align)) {
98  return 0;
99  } else {
100  return (k + 1) * m_separation;
101  }
102 
103  } else {
104  int m = max(si.m_nAttached[0], si.m_nAttached[1]);
105  if (m == 0) {
106  return 0;
107  } else {
108  return (m + 1) * m_separation;
109  }
110  }
111  }
112 
113  struct vInfo {
114  ATYPE rc[4];
115 
116  vInfo() { rc[0] = rc[1] = rc[2] = rc[3] = ATYPE(); }
117  };
118 
121  double m_cOverhang;
122 };
123 
124 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
Graph.h
Includes declaration of graph class.
ogdf::OrthoRep::VertexInfoUML
Further information about the cages of vertices in UML diagrams.
Definition: OrthoRep.h:264
ogdf::OrthoDir
OrthoDir
Definition: OrthoRep.h:56
ogdf::OrthoDir::West
@ West
ogdf::OrthoRep::SideInfoUML::m_adjGen
adjEntry m_adjGen
Definition: OrthoRep.h:231
ogdf::RoutingChannel::overhang
ATYPE overhang() const
Definition: RoutingChannel.h:67
ogdf::OrthoRep::SideInfoUML
Information about a side of a vertex in UML diagrams.
Definition: OrthoRep.h:228
ogdf::OrthoDir::South
@ South
ogdf::RoutingChannel::cOverhang
double cOverhang() const
Definition: RoutingChannel.h:64
OrthoRep.h
Declaration of orthogonal representation of planar graphs.
ogdf::OrthoRep
Orthogonal representation of an embedded graph.
Definition: OrthoRep.h:225
ogdf::RoutingChannel::operator()
const ATYPE & operator()(node v, OrthoDir dir) const
Definition: RoutingChannel.h:54
GraphList.h
Decralation of GraphElement and GraphList classes.
ogdf::RoutingChannel::m_channel
NodeArray< vInfo > m_channel
Definition: RoutingChannel.h:119
ogdf::RoutingChannel::RoutingChannel
RoutingChannel(const Graph &G, ATYPE sep, double cOver)
Definition: RoutingChannel.h:50
ogdf::RoutingChannel::computeRoutingChannels
void computeRoutingChannels(const OrthoRep &OR, bool align=false)
Definition: RoutingChannel.h:69
ogdf::OrthoRep::cageInfo
const VertexInfoUML * cageInfo(node v) const
Definition: OrthoRep.h:321
ogdf::OrthoRep::SideInfoUML::m_nAttached
int m_nAttached[2]
Definition: OrthoRep.h:236
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::OrthoRep::VertexInfoUML::m_side
SideInfoUML m_side[4]
Definition: OrthoRep.h:267
ogdf::OrthoRep::SideInfoUML::totalAttached
int totalAttached() const
Definition: OrthoRep.h:245
ogdf::RoutingChannel::vInfo::vInfo
vInfo()
Definition: RoutingChannel.h:116
basic.h
Basic declarations, included by all source files.
ogdf::OrthoDir::East
@ East
ogdf::RoutingChannel::m_separation
ATYPE m_separation
Definition: RoutingChannel.h:120
ogdf::RoutingChannel::operator()
ATYPE & operator()(node v, OrthoDir dir)
Definition: RoutingChannel.h:58
ogdf::RoutingChannel::m_cOverhang
double m_cOverhang
Definition: RoutingChannel.h:121
ogdf::RoutingChannel::separation
ATYPE separation() const
Definition: RoutingChannel.h:61
ogdf::OrthoDir::North
@ North
ogdf::RoutingChannel::computeRoutingChannel
int computeRoutingChannel(const OrthoRep::SideInfoUML &si, const OrthoRep::SideInfoUML &siOpp, bool align=false)
Definition: RoutingChannel.h:93
ogdf::RoutingChannel::vInfo::rc
ATYPE rc[4]
Definition: RoutingChannel.h:114
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::RoutingChannel::vInfo
Definition: RoutingChannel.h:113
ogdf::RoutingChannel
Maintains input sizes for constructive compaction (size of routing channels, separation,...
Definition: RoutingChannel.h:47