Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

ClusterPlanarityModule.h
Go to the documentation of this file.
1 
33 #pragma once
34 
35 #include <ogdf/basic/GraphCopy.h>
36 #include <ogdf/basic/Module.h>
38 
39 namespace ogdf {
40 
42 public:
43  ClusterPlanarityModule() = default;
44 
45  virtual ~ClusterPlanarityModule() = default;
46 
48  virtual bool isClusterPlanar(const ClusterGraph& CG) {
49  Graph Gcopy;
50  ClusterGraph CGcopy(CG, Gcopy);
51  return isClusterPlanarDestructive(CGcopy, Gcopy);
52  };
53 
55 
58  virtual bool isClusterPlanarDestructive(ClusterGraph& CG, Graph& G) = 0;
59 
61  virtual bool clusterPlanarEmbed(ClusterGraph& CG, Graph& G) {
62  OGDF_ASSERT(&CG.constGraph() == &G);
63  Graph Gcopy;
64  ClusterArray<cluster> copyC(CG, nullptr);
65  NodeArray<node> copyN(G, nullptr);
66  EdgeArray<edge> copyE(G, nullptr);
67  ClusterGraph CGcopy(CG, Gcopy, copyC, copyN, copyE);
68 
69  if (!clusterPlanarEmbedClusterPlanarGraph(CGcopy, Gcopy)) {
70  return false;
71  } else {
72  EdgeArray<edge> origE(Gcopy, nullptr);
73  invertRegisteredArray(copyE, origE);
74  copyBackEmbedding(CG, G, CGcopy, Gcopy, copyC, copyN, copyE, origE);
75  return true;
76  }
77  }
78 
80 
89  throw std::runtime_error(
90  "Embedding is (currently) not implemented by this ClusterPlanarityModule!");
91  }
92 
93 protected:
94  virtual void copyBackEmbedding(ClusterGraph& CG, Graph& G, const ClusterGraph& CGcopy,
95  const Graph& Gcopy, const ClusterArray<cluster>& copyC, const NodeArray<node>& copyN,
96  const EdgeArray<edge>& copyE, const EdgeArray<edge>& origE) const {
97  CG.adjAvailable(true);
98  copyEmbedding(Gcopy, G, [&origE](adjEntry adj) { return origE.mapEndpoint(adj); });
99  for (cluster c : CG.clusters) {
100  c->adjEntries.clear();
101  for (adjEntry adj : copyC[c]->adjEntries) {
102  c->adjEntries.pushBack(origE.mapEndpoint(adj));
103  }
104  }
105  };
106 };
107 
108 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:54
ogdf::ClusterGraph::constGraph
const Graph & constGraph() const
Returns a reference to the underlying graph.
Definition: ClusterGraph.h:797
ogdf::ClusterArrayBase
RegisteredArray for labeling the clusters of a ClusterGraph.
Definition: ClusterGraph.h:304
ogdf::AdjElement
Class for adjacency list elements.
Definition: Graph_d.h:135
ogdf::ClusterElement
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:55
ogdf::ClusterGraph::clusters
internal::GraphObjectContainer< ClusterElement > clusters
The container containing all cluster objects.
Definition: ClusterGraph.h:377
invertRegisteredArray
void invertRegisteredArray(const RA1 &from, RA2 &to)
Copy data from a ABCArray<XYZ> to an XYZArray<ABC>
Definition: RegisteredArray.h:951
ogdf::ClusterGraph::adjAvailable
bool adjAvailable() const
Gets the availability status of the adjacency entries.
Definition: ClusterGraph.h:718
ogdf::Module
Base class for modules.
Definition: Module.h:47
ogdf::ClusterPlanarityModule::isClusterPlanar
virtual bool isClusterPlanar(const ClusterGraph &CG)
Returns true, if CG is cluster-planar, false otherwise.
Definition: ClusterPlanarityModule.h:48
ogdf::ClusterPlanarityModule::clusterPlanarEmbed
virtual bool clusterPlanarEmbed(ClusterGraph &CG, Graph &G)
Returns true, if CG is cluster-planar, false otherwise. If true, CG contains a cluster-planar embeddi...
Definition: ClusterPlanarityModule.h:61
GraphCopy.h
Declaration of graph copy classes.
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:651
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:862
ogdf::ClusterPlanarityModule::clusterPlanarEmbedClusterPlanarGraph
virtual bool clusterPlanarEmbedClusterPlanarGraph(ClusterGraph &CG, Graph &G)
Constructs a cluster-planar embedding of CG. CG has to be cluster-planar!
Definition: ClusterPlanarityModule.h:88
ogdf::ClusterElement::adjEntries
ListContainer< adjEntry, ClusterElement > adjEntries
The container containing the sorted list of adjacency entries of edges leaving this cluster.
Definition: ClusterGraph.h:80
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ClusterGraph.h
Derived class of GraphObserver providing additional functionality to handle clustered graphs.
ogdf::ClusterPlanarityModule::copyBackEmbedding
virtual void copyBackEmbedding(ClusterGraph &CG, Graph &G, const ClusterGraph &CGcopy, const Graph &Gcopy, const ClusterArray< cluster > &copyC, const NodeArray< node > &copyN, const EdgeArray< edge > &copyE, const EdgeArray< edge > &origE) const
Definition: ClusterPlanarityModule.h:94
Module.h
Declares base class for all module types.
ogdf::copyEmbedding
void copyEmbedding(const Graph &from, Graph &to, std::function< adjEntry(adjEntry)> adjMapFromTo)
ogdf::ClusterGraph
Representation of clustered graphs.
Definition: ClusterGraph.h:339
ogdf::ClusterPlanarityModule
Definition: ClusterPlanarityModule.h:41
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:709