Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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 
41 namespace ogdf {
42 class ClusterGraph;
43 class Graph;
44 
46 
50  class CGraph;
51  class CLinearSystem;
52 
53 public:
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 
144  static HananiTutteSolver* getSolver(const ClusterGraph& C);
145 
146 private:
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 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::HananiTutteCPlanarity::timesolve
int64_t timesolve() const
Definition: HananiTutteCPlanarity.h:140
ogdf::HananiTutteCPlanarity::m_stats
Stats m_stats
Definition: HananiTutteCPlanarity.h:147
ogdf::HananiTutteCPlanarity::numNodesPreproc
int numNodesPreproc() const
Definition: HananiTutteCPlanarity.h:126
ogdf::HananiTutteCPlanarity::status
Status status() const
Definition: HananiTutteCPlanarity.h:121
ClusterPlanarityModule.h
Declaration of ClusterPlanarityModule which implements a cluster-planarity test and,...
ogdf::HananiTutteCPlanarity::Verification
Verification
Definition: HananiTutteCPlanarity.h:83
ogdf::HananiTutteCPlanarity::numClustersPreproc
int numClustersPreproc() const
Definition: HananiTutteCPlanarity.h:130
ogdf::HananiTutteCPlanarity::Type
Type
Definition: HananiTutteCPlanarity.h:91
ogdf::HananiTutteCPlanarity::HananiTutteSolver
Definition: HananiTutteCPlanarity.h:66
ogdf::gml::Key::Graph
@ Graph
ogdf::HananiTutteCPlanarity::isClusterPlanar
bool isClusterPlanar(const ClusterGraph &CG) override
Returns true, if CG is cluster-planar, false otherwise.
Definition: HananiTutteCPlanarity.h:103
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::HananiTutteCPlanarity::numEdgesPreproc
int numEdgesPreproc() const
Definition: HananiTutteCPlanarity.h:128
ogdf::HananiTutteCPlanarity::timeCreateSparse
int64_t timeCreateSparse() const
Definition: HananiTutteCPlanarity.h:138
ogdf::HananiTutteCPlanarity::timePrepare
int64_t timePrepare() const
Definition: HananiTutteCPlanarity.h:136
ogdf::HananiTutteCPlanarity::Solver
Solver
Definition: HananiTutteCPlanarity.h:72
ogdf::HananiTutteCPlanarity::Status
Status
Definition: HananiTutteCPlanarity.h:73
ogdf::HananiTutteCPlanarity
C-planarity testing via Hanani-Tutte approach.
Definition: HananiTutteCPlanarity.h:49
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
ogdf::HananiTutteCPlanarity::Stats
Definition: HananiTutteCPlanarity.h:54
ogdf::HananiTutteCPlanarity::isClusterPlanarDestructive
bool isClusterPlanarDestructive(ClusterGraph &CG, Graph &G) override
Returns true, if CG is cluster-planar, false otherwise. In it is non-cluster-planar,...
Definition: HananiTutteCPlanarity.h:114
ogdf::HananiTutteCPlanarity::SubType
SubType
Definition: HananiTutteCPlanarity.h:92
ogdf::HananiTutteCPlanarity::stats
const Stats & stats() const
Definition: HananiTutteCPlanarity.h:142
ogdf::ClusterGraph
Representation of clustered graphs.
Definition: ClusterGraph.h:346
ogdf::ClusterPlanarityModule
Definition: ClusterPlanarityModule.h:48
ogdf::HananiTutteCPlanarity::numMatrixCols
int numMatrixCols() const
Definition: HananiTutteCPlanarity.h:134
ogdf::HananiTutteCPlanarity::numMatrixRows
int numMatrixRows() const
Definition: HananiTutteCPlanarity.h:132