Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

ClusterPlanRep.h
Go to the documentation of this file.
1 
33 #pragma once
34 
35 #include <ogdf/basic/Graph.h>
36 #include <ogdf/basic/HashArray.h>
37 #include <ogdf/basic/SList.h>
38 #include <ogdf/basic/basic.h>
39 #include <ogdf/basic/exceptions.h>
42 #include <ogdf/planarity/PlanRep.h>
43 
44 #include <iosfwd>
45 
46 namespace ogdf {
47 class ClusterGraphAttributes;
48 class CombinatorialEmbedding;
49 class Layout;
50 class OrthoRep;
51 
53 
57 public:
58  ClusterPlanRep(const ClusterGraphAttributes& acGraph, const ClusterGraph& clusterGraph);
59 
60  virtual ~ClusterPlanRep() { }
61 
62  void initCC(int i);
63 
64  //edge on the cluster boundary, adjSource
65  void setClusterBoundary(edge e) { setEdgeTypeOf(e, edgeTypeOf(e) | clusterPattern()); }
66 
68  return (edgeTypeOf(e) & clusterPattern()) == clusterPattern();
69  }
70 
71  const ClusterGraph& getClusterGraph() const { return *m_pClusterGraph; }
72 
82  void insertEdgePathEmbedded(edge eOrig, CombinatorialEmbedding& E,
83  const SList<adjEntry>& crossedEdges);
84 
85  void ModelBoundaries();
86 
87  //rootadj is set by ModelBoundaries
88  adjEntry externalAdj() { return m_rootAdj; }
89 
90  //structural alterations
91 
93  virtual void expand(bool lowDegreeExpand = false) override;
94 
95  virtual void expandLowDegreeVertices(OrthoRep& OR);
96 
98  virtual edge split(edge e) override {
99  edge eNew = PlanRep::split(e);
100 
101  //update edge to cluster info
102  m_edgeClusterID[eNew] = m_edgeClusterID[e];
103  m_nodeClusterID[eNew->source()] = m_edgeClusterID[e];
104 
105  return eNew;
106  }
107 
115  const auto sourceId = ClusterID(e->source());
116  const auto targetId = ClusterID(e->target());
117  cluster targetCluster = clusterOfIndex(targetId);
118 
119  if (sourceId == targetId) {
120  return targetCluster;
121  }
122 
123  cluster sourceCluster = clusterOfIndex(sourceId);
124 
125  if (sourceCluster == targetCluster->parent()) {
126  return sourceCluster;
127  }
128  if (targetCluster == sourceCluster->parent()) {
129  return targetCluster;
130  }
131  if (targetCluster->parent() == sourceCluster->parent()) {
132  return sourceCluster->parent();
133  }
134 
135  OGDF_ASSERT(false);
137  }
138 
139  inline int ClusterID(node v) const { return m_nodeClusterID[v]; }
140 
141  inline int ClusterID(edge e) const { return m_edgeClusterID[e]; }
142 
144  OGDF_ASSERT(m_clusterOfIndex.isDefined(i));
145  return m_clusterOfIndex[i];
146  }
147 
149  OGDF_ASSERT(!original(v));
150  OGDF_ASSERT(ClusterID(v) != -1);
151  return clusterOfIndex(ClusterID(v));
152  }
153 
154  //output functions
155  void writeGML(const char* fileName, const Layout& drawing);
156  void writeGML(const char* fileName);
157  void writeGML(std::ostream& os, const Layout& drawing);
158 
159 protected:
161  void convertClusterGraph(cluster act, AdjEntryArray<edge>& currentEdge,
162  AdjEntryArray<int>& outEdge);
163 
165  void insertBoundary(cluster C, AdjEntryArray<edge>& currentEdge, AdjEntryArray<int>& outEdge,
166  bool clusterIsLeaf);
167 
169  void reinsertEdge(edge e);
170 
171 private:
173 
176  }
177 
180 
183  //we maintain an array of index to cluster mappings (CG is const)
184  //cluster numbers don't need to be consecutive
186 };
187 
188 }
HashArray.h
Declaration and implementation of HashArray class.
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::ClusterPlanRep::ClusterID
int ClusterID(edge e) const
Definition: ClusterPlanRep.h:141
ogdf::ClusterPlanRep::clusterOfIndex
cluster clusterOfIndex(int i)
Definition: ClusterPlanRep.h:143
Graph.h
Includes declaration of graph class.
ogdf::UMLEdgeTypeConstants::SecCluster
@ SecCluster
exceptions.h
Definition of exception classes.
ogdf::PlanRep
Planarized representations (of a connected component) of a graph.
Definition: PlanRep.h:69
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:66
ogdf::ClusterPlanRep::m_rootAdj
adjEntry m_rootAdj
Connects cluster on highest level with non cluster or same level.
Definition: ClusterPlanRep.h:179
ogdf::UMLEdgeTypeOffsets::Secondary
@ Secondary
ogdf::ClusterPlanRep
Planarized representations for clustered graphs.
Definition: ClusterPlanRep.h:56
ogdf::ClusterPlanRep::getClusterGraph
const ClusterGraph & getClusterGraph() const
Definition: ClusterPlanRep.h:71
ogdf::SList
Singly linked lists (maintaining the length of the list).
Definition: SList.h:845
ogdf::ClusterPlanRep::clusterPattern
edgeType clusterPattern()
Definition: ClusterPlanRep.h:174
ogdf::edgeType
long long edgeType
Definition: EdgeTypePatterns.h:42
ogdf::ClusterPlanRep::clusterOfDummy
cluster clusterOfDummy(node v)
Definition: ClusterPlanRep.h:148
ogdf::ClusterPlanRep::ClusterID
int ClusterID(node v) const
Definition: ClusterPlanRep.h:139
PlanRep.h
Declaration of a base class for planar representations of graphs and cluster graphs.
ogdf::AdjElement
Class for adjacency list elements.
Definition: Graph_d.h:142
ogdf::AlgorithmFailureException
Exception thrown when an algorithm realizes an internal bug that prevents it from continuing.
Definition: exceptions.h:247
ogdf::ClusterPlanRep::m_edgeClusterID
EdgeArray< int > m_edgeClusterID
Definition: ClusterPlanRep.h:181
ogdf::ClusterElement
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:62
ogdf::ClusterGraphAttributes
Stores additional attributes of a clustered graph (like layout information).
Definition: ClusterGraphAttributes.h:52
ogdf::ClusterPlanRep::m_pClusterGraph
const ClusterGraph * m_pClusterGraph
Definition: ClusterPlanRep.h:172
ogdf::Layout
Stores a layout of a graph (coordinates of nodes, bend points of edges).
Definition: Layout.h:49
ogdf::ClusterPlanRep::clusterOfEdge
cluster clusterOfEdge(edge e)
Returns cluster of edge e.
Definition: ClusterPlanRep.h:114
OGDF_THROW
#define OGDF_THROW(CLASS)
Replacement for throw.
Definition: exceptions.h:74
ogdf::OrthoRep
Orthogonal representation of an embedded graph.
Definition: OrthoRep.h:225
SList.h
Declaration of singly linked lists and iterators.
ogdf::ClusterPlanRep::m_clusterOfIndex
HashArray< int, cluster > m_clusterOfIndex
Definition: ClusterPlanRep.h:185
ogdf::HashArray
Indexed arrays using hashing for element access.
Definition: HashArray.h:93
ogdf::ClusterPlanRep::~ClusterPlanRep
virtual ~ClusterPlanRep()
Definition: ClusterPlanRep.h:60
ogdf::EdgeElement::source
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:398
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::ClusterPlanRep::externalAdj
adjEntry externalAdj()
Definition: ClusterPlanRep.h:88
ogdf::ClusterPlanRep::split
virtual edge split(edge e) override
Splits edge e, updates clustercage lists if necessary and returns new edge.
Definition: ClusterPlanRep.h:98
basic.h
Basic declarations, included by all source files.
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::ClusterPlanRep::isClusterBoundary
bool isClusterBoundary(edge e)
Definition: ClusterPlanRep.h:67
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:363
ClusterGraph.h
Derived class of GraphObserver providing additional functionality to handle clustered graphs.
ogdf::ClusterElement::parent
cluster parent()
Returns the parent of the cluster.
Definition: ClusterGraph.h:153
ogdf::ClusterPlanRep::setClusterBoundary
void setClusterBoundary(edge e)
Definition: ClusterPlanRep.h:65
ogdf::EdgeElement::target
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:401
ogdf::ClusterGraph
Representation of clustered graphs.
Definition: ClusterGraph.h:346
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::PlanRep::split
virtual edge split(edge e) override
Splits edge e.
EdgeTypePatterns.h
Edge types and patterns for planar representations.
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:716
ogdf::ClusterPlanRep::m_nodeClusterID
NodeArray< int > m_nodeClusterID
Definition: ClusterPlanRep.h:182