Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

UpwardPlanRep.h
Go to the documentation of this file.
1 
33 #pragma once
34 
36 #include <ogdf/basic/Graph.h>
37 #include <ogdf/basic/GraphCopy.h>
38 #include <ogdf/basic/GraphList.h>
39 #include <ogdf/basic/SList.h>
40 #include <ogdf/basic/basic.h>
41 
42 #include <iostream>
43 
44 namespace ogdf {
45 
46 
58 public:
60 
61 #if 0
62  //debug only
64 #endif
65 
66  /* @{
67  * \brief Creates a planarized representation with respect to \p Gamma.
68  * Gamma muss be an upward planar embedding with a fixed ext. face
69  * Precondition: the graph is a single source graph
70  */
71 
72  explicit UpwardPlanRep(
73  const CombinatorialEmbedding& Gamma); //upward planar embedding with a fixed ext. face
74 
75  UpwardPlanRep(const GraphCopy& GC, // must be upward embedded and single source
76  adjEntry adj_ext); // the right face of this adjEntry is the external face
77 
79  UpwardPlanRep(const UpwardPlanRep& UPR);
80 
83  : GraphCopy()
84  , isAugmented(false)
85  , t_hat(nullptr)
86  , s_hat(nullptr)
87  , extFaceHandle(nullptr)
88  , crossings(0)
89  // multisources(false)
90  {
91  m_Gamma.init(*this);
92  m_isSinkArc.init(*this, false);
93  m_isSourceArc.init(*this, false);
94  }
95 
96  virtual ~UpwardPlanRep() { }
97 
99  void insertEdgePathEmbedded(edge eOrig, SList<adjEntry> crossedEdges, EdgeArray<int>& cost);
100 
102  // pred. the graph muss be a sinlge source graph
103  // We construct node t and connect the sink-switches with t. The new arcs are sSinkArc.
104  // For simplicity we construct an additional edge (t,t_hat) (the extFaceArc), where t_hat is the super sink.
105  void augment();
106 
108  bool augmented() const { return isAugmented; }
109 
111  const CombinatorialEmbedding& getEmbedding() const { return m_Gamma; }
112 
113  CombinatorialEmbedding& getEmbedding() { return m_Gamma; }
114 
115  node getSuperSink() const { return t_hat; }
116 
117  node getSuperSource() const { return s_hat; }
118 
119  int numberOfCrossings() const { return crossings; }
120 
122  UpwardPlanRep& operator=(const UpwardPlanRep& copy);
123 
124  bool isSinkArc(edge e) const { return m_isSinkArc[e]; }
125 
126  bool isSourceArc(edge e) const { return m_isSourceArc[e]; }
127 
130  adjEntry sinkSwitchOf(node v) { return m_sinkSwitchOf[v]; }
131 
133  adjEntry getAdjEntry(const CombinatorialEmbedding& Gamma, node v, face f) const;
134 
135  //return the left in edge of node v.
137  if (v->indeg() == 0) {
138  return nullptr;
139  }
140 
141  adjEntry adjFound = nullptr;
142  for (adjEntry adj : v->adjEntries) {
143  if (adj->theEdge()->target() == v && adj->cyclicSucc()->theEdge()->source() == v) {
144  adjFound = adj;
145  break;
146  }
147  }
148  return adjFound;
149  }
150 
151  // debug
152  void outputFaces(const CombinatorialEmbedding& embedding) const {
153  std::cout << std::endl << "Face UPR " << std::endl;
154  for (face f : embedding.faces) {
155  std::cout << "face " << f->index() << ": ";
156  adjEntry adjNext = f->firstAdj();
157  do {
158  std::cout << adjNext->theEdge() << "; ";
159  adjNext = adjNext->faceCycleSucc();
160  } while (adjNext != f->firstAdj());
161  std::cout << std::endl;
162  }
163  if (embedding.externalFace() != nullptr) {
164  std::cout << "ext. face of the graph is: " << embedding.externalFace()->index()
165  << std::endl;
166  } else {
167  std::cout << "no ext. face set." << std::endl;
168  }
169  }
170 
171 
172 protected:
173  bool isAugmented;
174 
176 
178 
180 
181  // sinkArk are edges which are added to transform the original graph to single sink graph.
182  // note: the extFaceHandle is a sink arc.
184 
185  // source arc are edges which are added to transform the original graph to a single source graph
187 
188  // 0 if node v is not a non-top-sink-switch of a internal face.
189  // else v is (non-top) sink-switch of f (= right face of adjEntry).
191 
192  adjEntry extFaceHandle; // the right face of this adjEntry is always the ext. face
193 
195 
196 
197 private:
198  void computeSinkSwitches();
199 
201  void initMe();
202 
203  void copyMe(const UpwardPlanRep& UPR);
204 
205  void removeSinkArcs(SList<adjEntry>& crossedEdges);
206 
207  void constructSinkArcs(face f, node t);
208 };
209 
210 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::UpwardPlanRep::m_sinkSwitchOf
NodeArray< adjEntry > m_sinkSwitchOf
Definition: UpwardPlanRep.h:190
Graph.h
Includes declaration of graph class.
ogdf::UpwardPlanRep::augmented
bool augmented() const
return true if graph is augmented to a single source single sink graph
Definition: UpwardPlanRep.h:108
ogdf::SubgraphUpwardPlanarizer
Takes an acyclic connected non-upward-planar graph and planarizes it, i.e., we obtain an upward-plana...
Definition: SubgraphUpwardPlanarizer.h:70
ogdf::UpwardPlanRep::m_isSinkArc
EdgeArray< bool > m_isSinkArc
Definition: UpwardPlanRep.h:183
ogdf::UpwardPlanRep::crossings
int crossings
Definition: UpwardPlanRep.h:194
ogdf::SList
Singly linked lists (maintaining the length of the list).
Definition: SList.h:845
ogdf::UpwardPlanRep::~UpwardPlanRep
virtual ~UpwardPlanRep()
Definition: UpwardPlanRep.h:96
ogdf::GraphCopy
Copies of graphs supporting edge splitting.
Definition: GraphCopy.h:391
ogdf::UpwardPlanRep::sinkSwitchOf
adjEntry sinkSwitchOf(node v)
0 if node v is not a sink switch (not the top sink switch !!) of an internal face....
Definition: UpwardPlanRep.h:130
ogdf::UpwardPlanRep::numberOfCrossings
int numberOfCrossings() const
Definition: UpwardPlanRep.h:119
ogdf::UpwardPlanRep::extFaceHandle
adjEntry extFaceHandle
Definition: UpwardPlanRep.h:192
ogdf::UpwardPlanRep::UpwardPlanRep
UpwardPlanRep()
standart constructor
Definition: UpwardPlanRep.h:82
ogdf::FixedEmbeddingUpwardEdgeInserter
Edge insertion module that inserts each edge optimally into a fixed embedding.
Definition: FixedEmbeddingUpwardEdgeInserter.h:48
ogdf::UpwardPlanRep::getEmbedding
const CombinatorialEmbedding & getEmbedding() const
return the upward planar embedding
Definition: UpwardPlanRep.h:111
ogdf::UpwardPlanRep::isAugmented
bool isAugmented
the UpwardPlanRep is augmented to a single source and single sink graph
Definition: UpwardPlanRep.h:173
ogdf::UpwardPlanRep::m_isSourceArc
EdgeArray< bool > m_isSourceArc
Definition: UpwardPlanRep.h:186
ogdf::UpwardPlanRep::isSinkArc
bool isSinkArc(edge e) const
Definition: UpwardPlanRep.h:124
ogdf::AdjElement
Class for adjacency list elements.
Definition: Graph_d.h:142
ogdf::FaceElement::firstAdj
adjEntry firstAdj() const
Returns the first adjacency element in the face.
Definition: CombinatorialEmbedding.h:148
ogdf::UpwardPlanRep::t_hat
node t_hat
< embedding og this UpwardPlanRep
Definition: UpwardPlanRep.h:177
ogdf::UpwardPlanRep::leftInEdge
adjEntry leftInEdge(node v) const
Definition: UpwardPlanRep.h:136
ogdf::GraphCopyBase::init
void init(const Graph &G)
Re-initializes the copy using G, creating copies for all nodes and edges in G.
Definition: GraphCopy.h:73
ogdf::AdjElement::theEdge
edge theEdge() const
Returns the edge associated with this adjacency entry.
Definition: Graph_d.h:160
Minisat::Internal::copy
static void copy(const T &from, T &to)
Definition: Alg.h:61
ogdf::ConstCombinatorialEmbedding::faces
internal::GraphObjectContainer< FaceElement > faces
The container containing all face objects.
Definition: CombinatorialEmbedding.h:230
SList.h
Declaration of singly linked lists and iterators.
GraphList.h
Decralation of GraphElement and GraphList classes.
ogdf::NodeElement::adjEntries
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
Definition: Graph_d.h:271
ogdf::UpwardPlanRep::s_hat
node s_hat
the super source
Definition: UpwardPlanRep.h:179
ogdf::NodeElement::indeg
int indeg() const
Returns the indegree of the node.
Definition: Graph_d.h:277
ogdf::EdgeElement::source
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:398
GraphCopy.h
Declaration of graph copy classes.
ogdf::UpwardPlanRep::getSuperSink
node getSuperSink() const
Definition: UpwardPlanRep.h:115
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::AdjElement::cyclicSucc
adjEntry cyclicSucc() const
Returns the cyclic successor in the adjacency list.
Definition: Graph_d.h:354
ogdf::ConstCombinatorialEmbedding::externalFace
face externalFace() const
Returns the external face.
Definition: CombinatorialEmbedding.h:304
ogdf::FaceElement::index
int index() const
Returns the index of the face.
Definition: CombinatorialEmbedding.h:145
ogdf::UpwardPlanRep::m_Gamma
CombinatorialEmbedding m_Gamma
Definition: UpwardPlanRep.h:175
basic.h
Basic declarations, included by all source files.
CombinatorialEmbedding.h
Declaration of CombinatorialEmbedding and face.
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::CombinatorialEmbedding
Combinatorial embeddings of planar graphs with modification functionality.
Definition: CombinatorialEmbedding.h:406
ogdf::AdjElement::faceCycleSucc
adjEntry faceCycleSucc() const
Returns the cyclic successor in face.
Definition: Graph_d.h:212
ogdf::UpwardPlanRep::outputFaces
void outputFaces(const CombinatorialEmbedding &embedding) const
Definition: UpwardPlanRep.h:152
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:363
ogdf::UpwardPlanRep
Upward planarized representations (of a connected component) of a graph.
Definition: UpwardPlanRep.h:57
ogdf::EdgeElement::target
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:401
ogdf::UpwardPlanRep::isSourceArc
bool isSourceArc(edge e) const
Definition: UpwardPlanRep.h:126
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::UpwardPlanRep::getEmbedding
CombinatorialEmbedding & getEmbedding()
Definition: UpwardPlanRep.h:113
ogdf::UpwardPlanRep::getSuperSource
node getSuperSource() const
Definition: UpwardPlanRep.h:117
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:716
ogdf::FaceElement
Faces in a combinatorial embedding.
Definition: CombinatorialEmbedding.h:118