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/Graph.h>
36 #include <ogdf/basic/GraphCopy.h>
37 #include <ogdf/basic/GraphList.h>
38 #include <ogdf/basic/List.h>
39 #include <ogdf/basic/Module.h>
40 #include <ogdf/basic/basic.h>
42 
43 #include <functional>
44 #include <stdexcept>
45 
46 namespace ogdf {
47 
49 public:
50  ClusterPlanarityModule() = default;
51 
52  virtual ~ClusterPlanarityModule() = default;
53 
55  virtual bool isClusterPlanar(const ClusterGraph& CG) {
56  Graph Gcopy;
57  ClusterGraph CGcopy(CG, Gcopy);
58  return isClusterPlanarDestructive(CGcopy, Gcopy);
59  };
60 
62 
65  virtual bool isClusterPlanarDestructive(ClusterGraph& CG, Graph& G) = 0;
66 
68  virtual bool clusterPlanarEmbed(ClusterGraph& CG, Graph& G) {
69  OGDF_ASSERT(&CG.constGraph() == &G);
70  Graph Gcopy;
71  ClusterArray<cluster> copyC(CG, nullptr);
72  NodeArray<node> copyN(G, nullptr);
73  EdgeArray<edge> copyE(G, nullptr);
74  ClusterGraph CGcopy(CG, Gcopy, copyC, copyN, copyE);
75 
76  if (!clusterPlanarEmbedClusterPlanarGraph(CGcopy, Gcopy)) {
77  return false;
78  } else {
79  EdgeArray<edge> origE(Gcopy, nullptr);
80  invertRegisteredArray(copyE, origE);
81  copyBackEmbedding(CG, G, CGcopy, Gcopy, copyC, copyN, copyE, origE);
82  return true;
83  }
84  }
85 
87 
96  throw std::runtime_error(
97  "Embedding is (currently) not implemented by this ClusterPlanarityModule!");
98  }
99 
100 protected:
101  virtual void copyBackEmbedding(ClusterGraph& CG, Graph& G, const ClusterGraph& CGcopy,
102  const Graph& Gcopy, const ClusterArray<cluster>& copyC, const NodeArray<node>& copyN,
103  const EdgeArray<edge>& copyE, const EdgeArray<edge>& origE) const {
104  CG.adjAvailable(true);
105  copyEmbedding(Gcopy, G, [&origE](adjEntry adj) { return origE.mapEndpoint(adj); });
106  for (cluster c : CG.clusters) {
107  c->adjEntries.clear();
108  for (adjEntry adj : copyC[c]->adjEntries) {
109  c->adjEntries.pushBack(origE.mapEndpoint(adj));
110  }
111  }
112  };
113 };
114 
115 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
Graph.h
Includes declaration of graph class.
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:66
ogdf::ClusterGraph::constGraph
const Graph & constGraph() const
Returns a reference to the underlying graph.
Definition: ClusterGraph.h:804
ogdf::ClusterArrayBase
RegisteredArray for labeling the clusters of a ClusterGraph.
Definition: ClusterGraph.h:311
ogdf::AdjElement
Class for adjacency list elements.
Definition: Graph_d.h:142
ogdf::ClusterElement
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:62
ogdf::ClusterGraph::clusters
internal::GraphObjectContainer< ClusterElement > clusters
The container containing all cluster objects.
Definition: ClusterGraph.h:384
invertRegisteredArray
void invertRegisteredArray(const RA1 &from, RA2 &to)
Copy data from a ABCArray<XYZ> to an XYZArray<ABC>
Definition: RegisteredArray.h:960
ogdf::ClusterGraph::adjAvailable
bool adjAvailable() const
Gets the availability status of the adjacency entries.
Definition: ClusterGraph.h:725
ogdf::Module
Base class for modules.
Definition: Module.h:49
ogdf::ClusterPlanarityModule::isClusterPlanar
virtual bool isClusterPlanar(const ClusterGraph &CG)
Returns true, if CG is cluster-planar, false otherwise.
Definition: ClusterPlanarityModule.h:55
GraphList.h
Decralation of GraphElement and GraphList classes.
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:68
GraphCopy.h
Declaration of graph copy classes.
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
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:95
ogdf::ClusterElement::adjEntries
ListContainer< adjEntry, ClusterElement > adjEntries
The container containing the sorted list of adjacency entries of edges leaving this cluster.
Definition: ClusterGraph.h:87
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
ClusterGraph.h
Derived class of GraphObserver providing additional functionality to handle clustered graphs.
List.h
Declaration of doubly linked lists and iterators.
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:101
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:346
ogdf::ClusterPlanarityModule
Definition: ClusterPlanarityModule.h:48
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:716