55 namespace boyer_myrvold {
56 class BoyerMyrvoldInit;
103 bool extractSubgraph,
105 :
BoyerMyrvoldPlanar(g, bundles, static_cast<int>(embeddingGrade), limitStructures, output, randomness, avoidE2Minors, extractSubgraph, edgeCosts)
123 bool deleteFlipFlags);
133 void seed(
const std::minstd_rand rand) {
144 return m_dfi[w] > 0 && (!m_backedgeFlags[w].empty() || !m_pertinentRoots[w].empty());
150 return m_dfi[w] > 0 && pertinent(w) && !externallyActive(w, v);
156 if (m_dfi[w] <= 0)
return false;
157 if (m_leastAncestor[w] < v)
return true;
158 return !m_separatedDFSChildList[w].empty() && m_lowPoint[m_separatedDFSChildList[w].front()] < v;
164 if (m_dfi[w] <= 0)
return true;
165 if (!m_backedgeFlags[w].empty() || !m_pertinentRoots[w].empty()
166 || m_leastAncestor[w] < v)
return false;
167 return m_separatedDFSChildList[w].empty() || m_lowPoint[m_separatedDFSChildList[w].front()] >= v;
180 if (m_dfi[w] <= 0)
return 0;
181 if (!m_pertinentRoots[w].empty() || !m_backedgeFlags[w].empty()) {
183 if (m_leastAncestor[w] < v)
return 2;
184 if (m_separatedDFSChildList[w].empty())
return 1;
185 return m_lowPoint[m_separatedDFSChildList[w].front()] < v ? 2 : 1;
188 if (m_leastAncestor[w] < v)
return 3;
189 if (m_separatedDFSChildList[w].empty())
return 0;
190 return m_lowPoint[m_separatedDFSChildList[w].front()] < v ? 3 : 0;
205 adjEntry adj = m_link[direction][w];
208 if (w->
degree() > 1) direction =
220 adjEntry adj = beforeShortCircuitEdge(w,direction);
223 if (w->
degree() > 1) direction =
235 return m_link[direction][v]->theNode();
244 return beforeShortCircuitEdge(v,direction)->theNode();
253 return (m_beforeSCE[direction][v]==
nullptr) ? m_link[direction][v] : m_beforeSCE[direction][v];
259 node activeSuccessor(
node w,
int& direction,
int v,
int& info)
const;
265 return activeSuccessor(w,direction,v,info);
276 bool between =
false;
277 while (root !=
nullptr) {
278 root = successorOnExternalFace(root,dir);
279 if (between && pertinent(root)) {
282 if (root == stopx || root == stopy) {
295 <<
"\nprintNodeInfo(" << m_dfi[v] <<
"): " 303 std::cout << adj->
twinNode() <<
" ";
313 void embedBackedges(
const node v,
const int v_dir,
const node w,
const int w_dir);
316 void createShortCircuitEdge(
const node v,
const int v_dir,
317 const node w,
const int w_dir);
335 void mergeUnprocessedNodes();
340 void postProcessEmbedding();
364 bool m_extractSubgraph =
true;
469 return lhs >
static_cast<int>(rhs);
473 return lhs ==
static_cast<int>(rhs);
477 return lhs !=
static_cast<int>(rhs);
481 return lhs <= static_cast<int>(rhs);
Declaration of singly linked lists and iterators.
NodeArray< ListPure< node > > m_separatedDFSChildList
A list to all separated DFS-children of node.
Wrapper class used for preprocessing and valid invocation of the planarity test.
Data type for general directed graphs (adjacency list representation).
bool inactive(node w, int v)
Checks whether real node w is inactive while embedding node with DFI v.
NodeArray< node > m_realVertex
Link to non-virtual vertex of a virtual Vertex.
Array< node > m_nodeFromDFI
Returns appropriate node from given DFI.
EmbeddingGrade
Denotes the different embedding options.
int degree() const
Returns the degree of the node (indegree + outdegree).
NodeArray< int > m_numUnembeddedBackedgesInBicomp
Stores for each (virtual) bicomp root how many backedges to its bicomp still have to be embedded...
const double m_randomness
bool externallyActive(node w, int v) const
Checks whether real node w is externally active while embedding node with DFI v.
A Kuratowski Structure is a special graph structure containing severals subdivisions.
NodeArray< int > m_lowPoint
The lowpoint of each node.
NodeArray< int > m_leastAncestor
The DFI of the least ancestor node over all backedges.
node constSuccessorOnExternalFace(node v, int direction)
Returns the successornode on the external face in given direction.
const bool m_limitStructures
NodeArray< bool > m_flipped
Iff true, the node is the root of a bicomp which has to be flipped.
EdgeArray< BoyerMyrvoldEdgeType > m_edgeType
Contains the type of each edge.
bool internallyActive(node w, int v) const
Checks whether real node w is internally active while embedding node with DFI v.
bool operator>(int lhs, BoyerMyrvoldPlanar::EmbeddingGrade rhs)
int infoAboutNode(node w, int v) const
Checks all dynamic information about a node w while embedding node with DFI v.
void printNodeInfo(node v)
Prints informations about node v.
NodeArray< ListIterator< node > > m_pNodeInParent
Pointer to node contained in the DFSChildList of his parent, if exists.
This class is used in the Boyer-Myrvold planarity test for preprocessing purposes.
NodeArray< adjEntry > m_adjParent
The adjEntry which goes from DFS-parent to current vertex.
NodeArray< int > m_visited
This Array keeps track of all vertices that are visited by current walkup.
Declaration and implementation of EdgeArray class.
node successorWithoutShortCircuit(node w, int &direction)
Walks upon external face in given direction avoiding short circuit edges.
const bool m_avoidE2Minors
node constSuccessorWithoutShortCircuit(node v, int direction) const
Walks upon external face in direction avoiding short circuit edges.
NodeArray< edge > m_visitedWithBackedge
Stores for each (real) non-root vertex v with which backedge it was visited during the walkup...
adjEntry beforeShortCircuitEdge(node v, int direction) const
Returns underlying former adjEntry, if a short circuit edge in direction of v exists.
const int m_embeddingGrade
Graph & m_g
Input graph, which can be altered.
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
Class for the representation of edges.
NodeArray< SListPure< node > > m_pertinentRoots
List of virtual bicomp roots, that are pertinent to the current embedded node.
Class for the representation of nodes.
Declaration and implementation of NodeArray class.
const EdgeArray< int > * m_edgeCosts
node successorOnExternalFace(node w, int &direction) const
Walks upon external face in the given direction starting at w.
NodeArray< SListPure< adjEntry > > m_backedgeFlags
Holds information, if node is the source of a backedge.
bool wNodesExist(node root, node stopx, node stopy) const
Checks, if one ore more wNodes exist between the two stopping vertices stopx and stopy.
This class collects information about Kuratowski Subdivisions which is used for extraction later...
NodeArray< int > m_highestSubtreeDFI
The highest DFI in a subtree with node as root.
EdgeArray< node > m_pointsToRoot
Identifies the rootnode of the child bicomp the given backedge points to.
void seed(const std::minstd_rand rand)
Seeds the random generator for performing a random DFS. If this method is never called the random gen...
int m_flippedNodes
The whole number of bicomps, which have to be flipped.
This class implements the extended BoyerMyrvold planarity embedding algorithm.
static const int DirectionCCW
Direction for counterclockwise traversal.
BoyerMyrvoldPlanar(Graph &g, bool bundles, EmbeddingGrade embeddingGrade, bool limitStructures, SListPure< KuratowskiStructure > &output, double randomness, bool avoidE2Minors, bool extractSubgraph, const EdgeArray< int > *edgeCosts=nullptr)
Constructor, for parameters see BoyerMyrvold.
adjEntry succ() const
Returns the successor in the adjacency list.
static const int DirectionCW
Direction for clockwise traversal.
bool pertinent(node w) const
Checks whether node w is pertinent. w has to be non-virtual.
NodeArray< int > m_dfi
The one and only DFI-NodeArray.
The namespace for all OGDF objects.
bool operator<=(int lhs, BoyerMyrvoldPlanar::EmbeddingGrade rhs)
BoyerMyrvoldEdgeType
Type of edge.
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
bool operator==(const Tuple2< E1, E2 > &t1, const Tuple2< E1, E2 > &t2)
Equality operator for 2-tuples.
node theNode() const
Returns the node whose adjacency list contains this element.
bool operator!=(const Tuple2< E1, E2 > &t1, const Tuple2< E1, E2 > &t2)
Inequality operator for 2-tuples.
Class for adjacency list elements.
node constActiveSuccessor(node w, int direction, int v, int &info) const
Walks upon external face in the given direction (without changing it) until an active vertex is reach...
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Declaration of doubly linked lists and iterators.
SListPure< KuratowskiStructure > & m_output
Data structure for the Kuratowski subdivisions, which will be returned.