68template<
typename TCost>
70 using BlockType = std::pair<Graph*, EdgeArray<edge>*>;
92 (
m_block[i].first !=
nullptr) ? std::numeric_limits<int>::max() : 0;
182 if (G.numberOfEdges() < 9) {
192 for (
edge e : G.edges) {
193 if (!e->isSelfLoop()) {
202 for (
int i = 0; i <
nBlocks; i++) {
215 if (
copyV[e->source()] ==
nullptr) {
216 copyV[e->source()] =
bc->newNode();
219 if (
copyV[e->target()] ==
nullptr) {
220 copyV[e->target()] =
bc->newNode();
224 (*origE)[
bc->newEdge(
copyV[e->source()],
copyV[e->target()])] = e;
227 for (
node v : marked) {
243 for (
int i = 0; i <
nBlocks; i++) {
244 delete block[i].first;
245 delete block[i].second;
263 for (
int i = 0; i <
nBlocks; ++i) {
265 bestSolution[i] = (block[i].first !=
nullptr) ? std::numeric_limits<TCost>::max() : 0;
268 for (
int run = 0; run <
nRuns; ++run) {
269 for (
int i = 0; i <
nBlocks; ++i) {
270 if (bestSolution[i] > 1) {
271 const Graph&
B = *block[i].first;
282 if (
pCost ==
nullptr) {
303 for (
int i = 0; i <
nBlocks; ++i) {
321 for (
unsigned int i = 0; i <
nThreads - 1; ++i) {
328 for (
unsigned int i = 0; i <
nThreads - 1; ++i) {
346 for (
node v : G.nodes) {
347 for (
adjEntry adj : v->adjEntries) {
348 edge e = adj->theEdge();
350 PlanarLeafKey*
L =
new PlanarLeafKey(e);
357 for (
node v : G.nodes) {
359 outLeaves[
L->userStructKey()->opposite(v)].pushFront(
L);
367 for (
int i = 2; i < G.numberOfNodes(); i++) {
376 edge e = key->userStructKey();
381 for (
node v : G.nodes) {
383 PlanarLeafKey*
L =
inLeaves[v].popFrontRet();
396 for (
int i = 0; i <
nBlocks; ++i) {
Declaration of class PlanarLeafKey.
Declaration of interface for planar subgraph algorithms.
Declaration of class PlanarSubgraphPQTree.
Declaration of st-Numbering functions.
Declaration of Thread class representing threads.
Class for adjacency list elements.
The parameterized class Array implements dynamic arrays of type E.
INDEX size() const
Returns the size (number of elements) of the array.
Dynamic arrays indexed with edges.
Class for the representation of edges.
node opposite(node v) const
Returns the adjacent node different from v.
Data type for general directed graphs (adjacency list representation).
Doubly linked lists (maintaining the length of the list).
int size() const
Returns the number of elements in the list.
void clear()
Removes all elements from the list.
iterator pushBack(const E &x)
Adds element x at the end of the list.
virtual void emptyAllPertinentNodes()
Does a clean up after a reduction.
ReturnType
The return type of a module.
@ Feasible
The solution is feasible.
@ Optimal
The solution is optimal.
Dynamic arrays indexed with nodes.
Class for the representation of nodes.
The class template PQLeafKey is a derived class of class template PQBasicKey.
virtual void Cleanup()
Removes the entire PQ-tree.
ThreadMaster(const Array< BlockType > &block, const EdgeArray< TCost > *pCost, int runs)
int m_nBlocks
number of blocks
Array< List< edge > * > m_bestDelEdges
best solution for block
List< edge > * postNewResult(int i, List< edge > *pNewDelEdges)
std::atomic< int > m_runs
const Array< BlockType > & m_block
the blocks (graph and edge mapping)
bool considerBlock(int i) const
std::mutex m_mutex
thread synchronization
const EdgeArray< TCost > * m_pCost
edge cost (may be 0)
void buildSolution(List< edge > &delEdges)
Array< TCost > m_bestSolution
value of best solution for block
const Graph & block(int i) const
Worker & operator=(const Worker &other)
Worker(const Worker &other)
Worker(ThreadMaster *pMaster)
Computation of a planar subgraph using PQ-trees.
virtual PlanarSubgraphFast * clone() const override
Returns a new instance of fast planar subgraph with the same option settings.
static void doWorkHelper(ThreadMaster &master)
virtual Module::ReturnType doCall(const Graph &G, const List< edge > &preferedEdges, List< edge > &delEdges, const EdgeArray< TCost > *pCost, bool preferedImplyPlanar) override
Returns true, if G is planar, false otherwise.
int runs() const
Returns the current number of randomized runs.
static void planarize(const Graph &G, NodeArray< int > &numbering, List< edge > &delEdges)
Performs a planarization on a biconnected component of G.
PlanarSubgraphFast()
Creates an instance of the fast planar subgraph algorithm with default settings (runs = 10).
void seqCall(const Array< BlockType > &block, const EdgeArray< TCost > *pCost, int nRuns, bool randomize, List< edge > &delEdges)
Realizes the sequential implementation.
void runs(int nRuns)
Sets the number of randomized runs to nRuns.
void parCall(const Array< BlockType > &block, const EdgeArray< TCost > *pCost, int nRuns, unsigned int nThreads, List< edge > &delEdges)
Realizes the parallel implementation.
std::pair< Graph *, EdgeArray< edge > * > BlockType
int m_nRuns
The number of runs for randomization.
Interface for planar subgraph algorithms.
unsigned int maxThreads() const
Returns the maximal number of used threads.
virtual int Initialize(SListPure< PlanarLeafKey * > &leafKeys)
Initializes a new PQ-tree with a set of leaves.
void ReplaceRoot(SListPure< PlanarLeafKey * > &leafKeys)
Replaces the pertinent subtree by a set of new leaves.
virtual bool Reduction(SListPure< PlanarLeafKey * > &leafKeys, SList< PQLeafKey< edge, whaInfo *, bool > * > &eliminatedKeys)
Reduces a set of leaves.
Singly linked lists (maintaining the length of the list).
SListIterator< E > pushBack(const E &x)
Adds element x at the end of the list.
Threads supporting OGDF's memory management.
int biconnectedComponents(const Graph &G, EdgeArray< int > &component, int &nonEmptyComponents)
Computes the biconnected components of G.
int computeSTNumbering(const Graph &G, NodeArray< int > &numbering, node s=nullptr, node t=nullptr, bool randomized=false)
Computes an st-Numbering of G.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.
Declaration of simple graph algorithms.