Open
Graph Drawing
Framework

 v. 2025.10-dev (Foxglove)
 

Loading...
Searching...
No Matches
OnePlanarityBacktracking.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/Module.h>
36#include <ogdf/basic/basic.h>
39
40#include <list>
41#include <memory>
42#include <stack>
43#include <vector>
44
45namespace ogdf {
46class Graph;
47} // namespace ogdf
48
50class PartialSolutionFilter;
51
53
65private:
67 class DFSThread {
68 public:
71
74
77 std::stack<bool> m_branchStack;
78
80 DFSThread(EdgePairPartition& x, OnePlanarityBacktracking* s) : m_epp(x), m_solver(s) {
81 m_branchStack.push(true);
82 }
83
87 : m_epp(G, mode), m_solver(s) {
88 m_branchStack.push(true);
89 }
90
92 bool nextStep();
93
95 bool finished() const { return m_branchStack.empty(); }
96
98
103 bool branch();
104
106 void cleanUp(DFSThread& thread);
107 };
108
110 enum class NodeStatus {
111 CNT,
112 CUT,
113 SOL
114 };
115
116 std::list<DFSThread> m_threads;
117
120 int m_processedNodes = 0;
121
122public:
124
132 explicit OnePlanarityBacktracking(int maxThreads = 1000, int maxKuratowskis = 1000);
133
135
137
139
141
153 return test(OneplanMode::Normal, G, out);
154 }
155
157
172 return test(OneplanMode::IC, G, out);
173 }
174
176
189 return test(OneplanMode::NIC, G, out);
190 }
191
193 int processedNodes() const { return m_processedNodes; }
194
195protected:
196 std::vector<std::unique_ptr<PartialSolutionFilter>> m_filters;
197
198private:
201
204
207};
208}
Partial solutions for backtracking 1-Planarity.
Declares base class for all module types.
Declaration of the OnePlanarization class.
Declares base class for modules with timeout functionality.
Basic declarations, included by all source files.
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
ReturnType
The return type of a module.
Definition Module.h:52
class for timeout funtionality.
Definition Timeouter.h:46
A partial solution for a 1-Planarity instance, representing a node in the backtracking tree.
A class representing one depth-first search in the backtracking tree.
DFSThread(const Graph &G, OneplanMode mode, OnePlanarityBacktracking *s)
Creates a new DFS-thread associated with s and initializes it with a new EdgePairPartition for G with...
EdgePairPartition m_epp
The current partial solution considered by the DFSThread.
OnePlanarityBacktracking * m_solver
The associated solver.
bool finished() const
Returns whether the DFS-thread has terminated.
bool branch()
Computes the children of the current node in the search tree using Kuratowski-subdivisions.
void cleanUp(DFSThread &thread)
Proceeds to the next child if there are any left, otherwise reverts the changes to the partial soluti...
DFSThread(EdgePairPartition &x, OnePlanarityBacktracking *s)
Creates a new DFS-thread associated with s that starts with a copy of x.
bool nextStep()
Executes one step of the DFS and returns true if a solution was found.
std::stack< bool > m_branchStack
The DFS-stack. True indicates that new branches should be computed, false means that the changes in t...
A backtracking implementation for the 1-Planarity problem.
int processedNodes() const
Returns the number of search tree nodes that were processed in the previous run.
Module::ReturnType testOnePlanarity(const Graph &G, OnePlanarization *out=nullptr)
Tests whether G is 1-planar.
void push(DFSThread *t, EdgePairPartition *epp)
Creates a new DFS-thread for epp if there is space, otherwise pushes it to t.
Module::ReturnType testNICPlanarity(const Graph &G, OnePlanarization *out=nullptr)
Tests whether G is NIC-Planar.
Module::ReturnType testICPlanarity(const Graph &G, OnePlanarization *out=nullptr)
Tests whether G is IC-Planar.
NodeStatus verifyNode(EdgePairPartition *epp)
Determines whether a partial solution is a solution, non-realizable, or the search must continue.
OnePlanarityBacktracking(int maxThreads=1000, int maxKuratowskis=1000)
Creates a new solver.
NodeStatus
Classification of partial solutions in the search tree.
OnePlanarityBacktracking & operator=(const OnePlanarityBacktracking &)=delete
Module::ReturnType test(OneplanMode mode, const Graph &G, OnePlanarization *out=nullptr)
Runs the backtracking on G and writes the solution to out.
OnePlanarityBacktracking(const OnePlanarityBacktracking &)=delete
std::vector< std::unique_ptr< PartialSolutionFilter > > m_filters
The graph corresponding to a partial solution for the 1-Planarity problem.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:118
OneplanMode
The different modes for 1-Planarity.
The namespace for all OGDF objects.