Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
NodeSPQRRotation.h
Go to the documentation of this file.
1
31#pragma once
32
33#include <ogdf/basic/Graph.h>
36#include <ogdf/basic/List.h>
37#include <ogdf/basic/basic.h>
45
46#include <functional>
47
48namespace ogdf {
49class Logger;
50template<class E>
51class SList;
52} // namespace ogdf
53
54namespace ogdf::sync_plan {
55
58protected:
61
66
67 node findSPQRApex(node n, bool clear = false);
68
70
72
74 // room for improvement: mostly needed for the destructor clean-up, because NodeArray<unique_ptr> didn't compile previously
77
79
81 for (node n : spqr.spqrTree().nodes) {
82 delete rigids[n];
83 }
84 }
85 };
86
87public:
88 static Logger log;
89
90 explicit NodeSPQRRotation(const DynamicSPQRForest& _spqr, node n,
91 const NodeArray<GraphCopySimple*>& _rigids)
92 : spqr(_spqr)
93 , rigids(_rigids)
94 , highest_with_edges(spqr.spqrTree(), nullptr)
95 , edges(spqr.spqrTree())
96 , children(spqr.spqrTree()) {
97 OGDF_ASSERT(n != nullptr);
98 OGDF_ASSERT(n->graphOf() == &spqr.auxiliaryGraph());
99 OGDF_ASSERT(spqr.spqrroot(spqr.bccomp(n)) != nullptr);
100 OGDF_ASSERT(spqr.spqrproper(n->firstAdj()->theEdge()) != nullptr);
101 m_G = &spqr.auxiliaryGraph();
102 m_n = n;
103 m_incidentEdgeForLeaf.init(*this, nullptr);
104 m_graphNodeForInnerNode.init(*this, nullptr);
105 apex = findSPQRApex(n);
106 pc_tree::PCNode* root = makePCNode(apex, nullptr, nullptr);
107 // findSPQRApex(n, true); // clear arrays
108 OGDF_ASSERT(getRootNode() == root);
109 node o = spqr.original(n);
110 if (spqr.typeOfGNode(o) == BCTree::GNodeType::Normal) {
111 OGDF_ASSERT(getLeafCount() == o->degree());
112 } else {
113 OGDF_ASSERT(getLeafCount() <= o->degree());
114 }
115 OGDF_ASSERT(checkValid());
116 // room for improvement: reuse highest, edges and children arrays
117 }
118
120
121 void mapGraph(const Graph* G, const std::function<node(node)>& node_map,
122 const std::function<edge(edge)>& edge_map) {
123 OGDF_ASSERT(G != nullptr);
124 m_G = G;
125 m_n = node_map(m_n);
126 for (pc_tree::PCNode* n : pc_tree::FilteringPCTreeDFS(*this, getRootNode())) {
127 node& gn = m_graphNodeForInnerNode[n];
128 if (gn != nullptr) {
129 gn = node_map(gn);
130 }
131 }
132 for (pc_tree::PCNode* l : getLeaves()) {
133 edge& ie = m_incidentEdgeForLeaf[l];
134 if (ie != nullptr) {
135 ie = edge_map(ie);
136 }
137 if (knowsPartnerEdges()) {
138 for (edge& e : m_bundleEdgesForLeaf[l]) {
139 e = edge_map(e);
140 }
141 }
142 }
143 }
144};
145
146}
Declaration of class BCTree.
Declaration of class DynamicSPQRForest.
Includes declaration of graph class.
Declaration of graph copy classes.
Decralation of GraphElement and GraphList classes.
An intrusive list for the leaves of a PCTree.
Declaration of doubly linked lists and iterators.
An embedding tree representing, for a single node, all orders of incident edges in all planar embeddi...
A node in a PC-tree that is either a P-node, C-node or leaf.
A registry that allows labelling the nodes of a PC-tree.
Utils for PCTree::allNodes(), PCTree::innerNodes(), PCNode::children() and PCNode::neighbors().
Basic declarations, included by all source files.
Class for adjacency list elements.
Definition Graph_d.h:143
edge theEdge() const
Returns the edge associated with this adjacency entry.
Definition Graph_d.h:161
node original(node vH) const
Definition BCTree.h:527
const Graph & auxiliaryGraph() const
Returns the biconnected components graph.
Definition BCTree.h:428
GNodeType typeOfGNode(node vG) const
Definition BCTree.h:446
node bccomp(node vH) const override
Dynamic SPQR-forest.
node spqrroot(node vB) const
Returns the root of the SPQR-tree for a given B-component of the BC-tree.
node spqrproper(edge eH) const
const Graph & spqrTree() const
Returns the SPQR-tree graph.
Class for the representation of edges.
Definition Graph_d.h:364
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
Definition Graph_d.h:929
Centralized global and local logging facility working on streams like std::cout.
Definition Logger.h:102
Class for the representation of nodes.
Definition Graph_d.h:241
int degree() const
Returns the degree of the node (indegree + outdegree).
Definition Graph_d.h:284
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
Definition Graph_d.h:287
const Graph * graphOf() const
Returns the graph containing this node (debug only).
Definition Graph_d.h:345
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition Graph_d.h:659
A DFS or BFS through a PCTree.
This class represents the embedding tree of a single node in a biconnected component.
A node in a PC-tree that is either a P-node, C-node or leaf.
Definition PCNode.h:62
Derive embedding trees from an DynamicSPQRForest. Warning: breaks on certain parallel edge configurat...
void mapGraph(const Graph *G, const std::function< node(node)> &node_map, const std::function< edge(edge)> &edge_map)
NodeArray< SList< adjEntry > > edges
NodeSPQRRotation(const DynamicSPQRForest &_spqr, node n, const NodeArray< GraphCopySimple * > &_rigids)
NodeArray< SList< node > > children
const NodeArray< GraphCopySimple * > & rigids
pc_tree::PCNode * addLeaf(pc_tree::PCNode *n, adjEntry adj)
pc_tree::PCNode * makePCNode(node t, node t_parent, pc_tree::PCNode *parent)
node findSPQRApex(node n, bool clear=false)
const DynamicSPQRForest & spqr
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:52
The namespace for all OGDF objects.