Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
UpwardPlanRep.h
Go to the documentation of this file.
1
33#pragma once
34
36#include <ogdf/basic/Graph.h>
39#include <ogdf/basic/SList.h>
40#include <ogdf/basic/basic.h>
41
42#include <iostream>
43
44namespace ogdf {
45
46
58public:
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
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
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
114
115 node getSuperSink() const { return t_hat; }
116
117 node getSuperSource() const { return s_hat; }
118
119 int numberOfCrossings() const { return crossings; }
120
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
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
172protected:
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
197private:
199
201 void initMe();
202
203 void copyMe(const UpwardPlanRep& UPR);
204
205 void removeSinkArcs(SList<adjEntry>& crossedEdges);
206
208};
209
210}
Declaration of CombinatorialEmbedding and face.
Includes declaration of graph class.
Declaration of graph copy classes.
Decralation of GraphElement and GraphList classes.
Declaration of singly linked lists and iterators.
Basic declarations, included by all source files.
Class for adjacency list elements.
Definition Graph_d.h:143
edge theEdge() const
Returns the edge associated with this adjacency entry.
Definition Graph_d.h:161
adjEntry faceCycleSucc() const
Returns the cyclic successor in face.
Definition Graph_d.h:213
Combinatorial embeddings of planar graphs with modification functionality.
face externalFace() const
Returns the external face.
internal::GraphObjectContainer< FaceElement > faces
The container containing all face objects.
Class for the representation of edges.
Definition Graph_d.h:364
Faces in a combinatorial embedding.
int index() const
Returns the index of the face.
Edge insertion module that inserts each edge optimally into a fixed embedding.
void init(const Graph &G)
Re-initializes the copy using G, creating copies for all nodes and edges in G.
Definition GraphCopy.h:72
Copies of graphs supporting edge splitting.
Definition GraphCopy.h:390
Class for the representation of nodes.
Definition Graph_d.h:241
int indeg() const
Returns the indegree of the node.
Definition Graph_d.h:278
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
Definition Graph_d.h:272
Singly linked lists (maintaining the length of the list).
Definition SList.h:845
Takes an acyclic connected non-upward-planar graph and planarizes it, i.e., we obtain an upward-plana...
Upward planarized representations (of a connected component) of a graph.
void copyMe(const UpwardPlanRep &UPR)
UpwardPlanRep(const GraphCopy &GC, adjEntry adj_ext)
EdgeArray< bool > m_isSourceArc
void removeSinkArcs(SList< adjEntry > &crossedEdges)
NodeArray< adjEntry > m_sinkSwitchOf
CombinatorialEmbedding m_Gamma
bool augmented() const
return true if graph is augmented to a single source single sink graph
CombinatorialEmbedding & getEmbedding()
void augment()
convert to a single source single sink graph (result is not necessary a st-graph!).
node s_hat
the super source
UpwardPlanRep(const CombinatorialEmbedding &Gamma)
UpwardPlanRep()
standart constructor
UpwardPlanRep(const UpwardPlanRep &UPR)
copy constructor
void outputFaces(const CombinatorialEmbedding &embedding) const
bool isSourceArc(edge e) const
adjEntry getAdjEntry(const CombinatorialEmbedding &Gamma, node v, face f) const
return the adjEntry of v which right face is f.
bool isAugmented
the UpwardPlanRep is augmented to a single source and single sink graph
int numberOfCrossings() const
EdgeArray< bool > m_isSinkArc
const CombinatorialEmbedding & getEmbedding() const
return the upward planar embedding
void constructSinkArcs(face f, node t)
void insertEdgePathEmbedded(edge eOrig, SList< adjEntry > crossedEdges, EdgeArray< int > &cost)
same as insertEdgePath, but assumes that the graph is embedded
node getSuperSource() const
node getSuperSink() const
UpwardPlanRep & operator=(const UpwardPlanRep &copy)
Assignment operator.
bool isSinkArc(edge e) const
adjEntry leftInEdge(node v) const
void initMe()
only for planarizer !!!
adjEntry sinkSwitchOf(node v)
0 if node v is not a sink switch (not the top sink switch !!) of an internal face....
node t_hat
< embedding og this UpwardPlanRep
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition Graph_d.h:717
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition Graph_d.h:659
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
The namespace for all OGDF objects.