Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
ClusterPlanarityModule.h
Go to the documentation of this file.
1
33#pragma once
34
35#include <ogdf/basic/Graph.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
46namespace ogdf {
47
49public:
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
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
100protected:
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}
Derived class of GraphObserver providing additional functionality to handle clustered graphs.
Includes declaration of graph class.
Declaration of graph copy classes.
Decralation of GraphElement and GraphList classes.
Declaration of doubly linked lists and iterators.
Declares base class for all module types.
void invertRegisteredArray(const RA1 &from, RA2 &to)
Copy data from a ABCArray<XYZ> to an XYZArray<ABC>
Basic declarations, included by all source files.
Class for adjacency list elements.
Definition Graph_d.h:143
RegisteredArray for labeling the clusters of a ClusterGraph.
Representation of clusters in a clustered graph.
Representation of clustered graphs.
bool adjAvailable() const
Gets the availability status of the adjacency entries.
const Graph & constGraph() const
Returns a reference to the underlying graph.
internal::GraphObjectContainer< ClusterElement > clusters
The container containing all cluster objects.
virtual bool clusterPlanarEmbedClusterPlanarGraph(ClusterGraph &CG, Graph &G)
Constructs a cluster-planar embedding of CG. CG has to be cluster-planar!
virtual bool isClusterPlanar(const ClusterGraph &CG)
Returns true, if CG is cluster-planar, false otherwise.
virtual ~ClusterPlanarityModule()=default
virtual bool clusterPlanarEmbed(ClusterGraph &CG, Graph &G)
Returns true, if CG is cluster-planar, false otherwise. If true, CG contains a cluster-planar embeddi...
virtual bool isClusterPlanarDestructive(ClusterGraph &CG, Graph &G)=0
Returns true, if CG is cluster-planar, false otherwise. In it is non-cluster-planar,...
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
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
Base class for modules.
Definition Module.h:49
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
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:52
The namespace for all OGDF objects.
void copyEmbedding(const Graph &from, Graph &to, std::function< adjEntry(adjEntry)> adjMapFromTo)