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/HashArray.h>
39 #include <ogdf/planarity/PlanRep.h>
40 
41 namespace ogdf {
42 
44 
48 public:
49  ClusterPlanRep(const ClusterGraphAttributes& acGraph, const ClusterGraph& clusterGraph);
50 
51  virtual ~ClusterPlanRep() { }
52 
53  void initCC(int i);
54 
55  //edge on the cluster boundary, adjSource
56  void setClusterBoundary(edge e) { setEdgeTypeOf(e, edgeTypeOf(e) | clusterPattern()); }
57 
59  return (edgeTypeOf(e) & clusterPattern()) == clusterPattern();
60  }
61 
62  const ClusterGraph& getClusterGraph() const { return *m_pClusterGraph; }
63 
73  void insertEdgePathEmbedded(edge eOrig, CombinatorialEmbedding& E,
74  const SList<adjEntry>& crossedEdges);
75 
76  void ModelBoundaries();
77 
78  //rootadj is set by ModelBoundaries
79  adjEntry externalAdj() { return m_rootAdj; }
80 
81  //structural alterations
82 
84  virtual void expand(bool lowDegreeExpand = false) override;
85 
86  virtual void expandLowDegreeVertices(OrthoRep& OR);
87 
89  virtual edge split(edge e) override {
90  edge eNew = PlanRep::split(e);
91 
92  //update edge to cluster info
93  m_edgeClusterID[eNew] = m_edgeClusterID[e];
94  m_nodeClusterID[eNew->source()] = m_edgeClusterID[e];
95 
96  return eNew;
97  }
98 
106  const auto sourceId = ClusterID(e->source());
107  const auto targetId = ClusterID(e->target());
108  cluster targetCluster = clusterOfIndex(targetId);
109 
110  if (sourceId == targetId) {
111  return targetCluster;
112  }
113 
114  cluster sourceCluster = clusterOfIndex(sourceId);
115 
116  if (sourceCluster == targetCluster->parent()) {
117  return sourceCluster;
118  }
119  if (targetCluster == sourceCluster->parent()) {
120  return targetCluster;
121  }
122  if (targetCluster->parent() == sourceCluster->parent()) {
123  return sourceCluster->parent();
124  }
125 
126  OGDF_ASSERT(false);
128  }
129 
130  inline int ClusterID(node v) const { return m_nodeClusterID[v]; }
131 
132  inline int ClusterID(edge e) const { return m_edgeClusterID[e]; }
133 
135  OGDF_ASSERT(m_clusterOfIndex.isDefined(i));
136  return m_clusterOfIndex[i];
137  }
138 
140  OGDF_ASSERT(!original(v));
141  OGDF_ASSERT(ClusterID(v) != -1);
142  return clusterOfIndex(ClusterID(v));
143  }
144 
145  //output functions
146  void writeGML(const char* fileName, const Layout& drawing);
147  void writeGML(const char* fileName);
148  void writeGML(std::ostream& os, const Layout& drawing);
149 
150 protected:
152  void convertClusterGraph(cluster act, AdjEntryArray<edge>& currentEdge,
153  AdjEntryArray<int>& outEdge);
154 
156  void insertBoundary(cluster C, AdjEntryArray<edge>& currentEdge, AdjEntryArray<int>& outEdge,
157  bool clusterIsLeaf);
158 
160  void reinsertEdge(edge e);
161 
162 private:
164 
167  }
168 
171 
174  //we maintain an array of index to cluster mappings (CG is const)
175  //cluster numbers don't need to be consecutive
177 };
178 
179 }
HashArray.h
Declaration and implementation of HashArray class.
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::ClusterPlanRep::ClusterID
int ClusterID(edge e) const
Definition: ClusterPlanRep.h:132
ogdf::ClusterPlanRep::clusterOfIndex
cluster clusterOfIndex(int i)
Definition: ClusterPlanRep.h:134
ogdf::UMLEdgeTypeConstants::SecCluster
@ SecCluster
ogdf::PlanRep
Planarized representations (of a connected component) of a graph.
Definition: PlanRep.h:57
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:54
ogdf::ClusterPlanRep::m_rootAdj
adjEntry m_rootAdj
Connects cluster on highest level with non cluster or same level.
Definition: ClusterPlanRep.h:170
ogdf::UMLEdgeTypeOffsets::Secondary
@ Secondary
ogdf::ClusterPlanRep
Planarized representations for clustered graphs.
Definition: ClusterPlanRep.h:47
ogdf::ClusterPlanRep::getClusterGraph
const ClusterGraph & getClusterGraph() const
Definition: ClusterPlanRep.h:62
ogdf::SList
Singly linked lists (maintaining the length of the list).
Definition: SList.h:833
ogdf::ClusterPlanRep::clusterPattern
edgeType clusterPattern()
Definition: ClusterPlanRep.h:165
ogdf::edgeType
long long edgeType
Definition: EdgeTypePatterns.h:42
ogdf::ClusterPlanRep::clusterOfDummy
cluster clusterOfDummy(node v)
Definition: ClusterPlanRep.h:139
ogdf::ClusterPlanRep::ClusterID
int ClusterID(node v) const
Definition: ClusterPlanRep.h:130
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:135
ogdf::AlgorithmFailureException
Exception thrown when an algorithm realizes an internal bug that prevents it from continuing.
Definition: exceptions.h:243
ogdf::ClusterPlanRep::m_edgeClusterID
EdgeArray< int > m_edgeClusterID
Definition: ClusterPlanRep.h:172
ogdf::ClusterElement
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:55
ogdf::ClusterGraphAttributes
Stores additional attributes of a clustered graph (like layout information).
Definition: ClusterGraphAttributes.h:46
ogdf::ClusterPlanRep::m_pClusterGraph
const ClusterGraph * m_pClusterGraph
Definition: ClusterPlanRep.h:163
ogdf::Layout
Stores a layout of a graph (coordinates of nodes, bend points of edges).
Definition: Layout.h:46
ogdf::ClusterPlanRep::clusterOfEdge
cluster clusterOfEdge(edge e)
Returns cluster of edge e.
Definition: ClusterPlanRep.h:105
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::ClusterPlanRep::m_clusterOfIndex
HashArray< int, cluster > m_clusterOfIndex
Definition: ClusterPlanRep.h:176
ogdf::HashArray
Indexed arrays using hashing for element access.
Definition: HashArray.h:93
ogdf::ClusterPlanRep::~ClusterPlanRep
virtual ~ClusterPlanRep()
Definition: ClusterPlanRep.h:51
ogdf::EdgeElement::source
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:391
ClusterArray.h
Declaration and implementation of ClusterArray class.
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:651
ogdf::ClusterPlanRep::externalAdj
adjEntry externalAdj()
Definition: ClusterPlanRep.h:79
ogdf::ClusterPlanRep::split
virtual edge split(edge e) override
Splits edge e, updates clustercage lists if necessary and returns new edge.
Definition: ClusterPlanRep.h:89
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:397
ogdf::ClusterPlanRep::isClusterBoundary
bool isClusterBoundary(edge e)
Definition: ClusterPlanRep.h:58
ClusterGraphAttributes.h
Declares ClusterGraphAttributes, an extension of class GraphAttributes, to store clustergraph layout ...
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:356
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:146
ogdf::ClusterPlanRep::setClusterBoundary
void setClusterBoundary(edge e)
Definition: ClusterPlanRep.h:56
ogdf::EdgeElement::target
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:394
ogdf::ClusterGraph
Representation of clustered graphs.
Definition: ClusterGraph.h:339
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::PlanRep::split
virtual edge split(edge e) override
Splits edge e.
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:709
ogdf::ClusterPlanRep::m_nodeClusterID
NodeArray< int > m_nodeClusterID
Definition: ClusterPlanRep.h:173