Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
HananiTutteCPlanarity.h
Go to the documentation of this file.
1
33#pragma once
34
35#include <ogdf/basic/basic.h>
37
38#include <cstdint>
39#include <stdexcept>
40
41namespace ogdf {
42class ClusterGraph;
43class Graph;
44
46
50 class CGraph;
51 class CLinearSystem;
52
53public:
54 struct Stats {
55 int nRows = 0;
56 int nColumns = 0;
57 int nConditions = 0;
58 int nMoves = 0;
59
60 int64_t tPrepare = 0;
61 int64_t tCreateSparse = 0;
62 int64_t tSolve = 0;
63 int64_t tCheck = 0;
64 };
65
67 virtual ~HananiTutteSolver() = default;
68 virtual bool test(Stats& stats) = 0;
69 virtual bool verify(Stats& stats) = 0;
70 };
71
72 enum class Solver { HananiTutte, HananiTutteVerify, ILP };
73 enum class Status {
74 invalid,
75 emptyAfterPreproc,
76 cConnectedAfterPreproc,
77 nonPlanarAfterPreproc,
78 applyHananiTutte,
79 applyILP,
80 timeoutILP,
81 errorILP
82 };
83 enum class Verification {
84 cPlanar,
85 cPlanarVerified,
86 nonCPlanarVerified,
87 verificationFailed,
88 timeout
89 };
90
91 enum class Type : uint16_t { tVertex, tEdge };
92 enum class SubType : uint16_t {
93 stVertex,
94 stCluster,
95 stEdge,
96 stInnerCluster,
97 stOuterCluster,
98 stVertexCluster,
99 stClusterCluster,
100 stCrossCluster
101 };
102
103 bool isClusterPlanar(const ClusterGraph& CG) override {
104 Verification res = isCPlanar(CG, true, false, Solver::HananiTutteVerify);
105 if (res == Verification::cPlanar || res == Verification::cPlanarVerified) {
106 return true;
107 } else if (res == Verification::nonCPlanarVerified) {
108 return false;
109 } else {
110 throw std::runtime_error("Could not solve instance!");
111 }
112 }
113
115 return isClusterPlanar(CG);
116 }
117
118 Verification isCPlanar(const ClusterGraph& C, bool doPreproc = true, bool forceSolver = false,
119 Solver solver = Solver::HananiTutte);
120
121 Status status() const { return m_status; }
122
124 static void preprocessing(ClusterGraph& C, Graph& G);
125
126 int numNodesPreproc() const { return m_numNodesPreproc; }
127
128 int numEdgesPreproc() const { return m_numEdgesPreproc; }
129
130 int numClustersPreproc() const { return m_numClustersPreproc; }
131
132 int numMatrixRows() const { return m_stats.nRows; }
133
134 int numMatrixCols() const { return m_stats.nColumns; }
135
136 int64_t timePrepare() const { return m_stats.tPrepare; }
137
138 int64_t timeCreateSparse() const { return m_stats.tCreateSparse; }
139
140 int64_t timesolve() const { return m_stats.tSolve; }
141
142 const Stats& stats() const { return m_stats; }
143
145
146private:
148 Status m_status = Status::invalid;
149 int m_numNodesPreproc = 0;
150 int m_numEdgesPreproc = 0;
151 int m_numClustersPreproc = 0;
152};
153
154
155}
Declaration of ClusterPlanarityModule which implements a cluster-planarity test and,...
Basic declarations, included by all source files.
Representation of clustered graphs.
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
C-planarity testing via Hanani-Tutte approach.
bool isClusterPlanarDestructive(ClusterGraph &CG, Graph &G) override
Returns true, if CG is cluster-planar, false otherwise. In it is non-cluster-planar,...
Verification isCPlanar(const ClusterGraph &C, bool doPreproc=true, bool forceSolver=false, Solver solver=Solver::HananiTutte)
bool isClusterPlanar(const ClusterGraph &CG) override
Returns true, if CG is cluster-planar, false otherwise.
static void preprocessing(ClusterGraph &C, Graph &G)
static HananiTutteSolver * getSolver(const ClusterGraph &C)
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
The namespace for all OGDF objects.