Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

NodeSPQRRotation.h
Go to the documentation of this file.
1 
31 #pragma once
32 
33 #include <ogdf/basic/Graph.h>
34 #include <ogdf/basic/GraphCopy.h>
35 #include <ogdf/basic/GraphList.h>
36 #include <ogdf/basic/List.h>
37 #include <ogdf/basic/basic.h>
45 
46 #include <functional>
47 
48 namespace ogdf {
49 class Logger;
50 template<class E>
51 class SList;
52 } // namespace ogdf
53 
54 namespace ogdf::sync_plan {
55 
58 protected:
61 
66 
67  node findSPQRApex(node n, bool clear = false);
68 
69  pc_tree::PCNode* addLeaf(pc_tree::PCNode* n, adjEntry adj);
70 
71  pc_tree::PCNode* makePCNode(node t, node t_parent, pc_tree::PCNode* parent);
72 
73  struct RigidEmbedding {
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 
87 public:
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 
119  void mapPartnerEdges();
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 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::BCTree::original
node original(node vH) const
Definition: BCTree.h:522
Graph.h
Includes declaration of graph class.
ogdf::sync_plan::NodeSPQRRotation::log
static Logger log
Definition: NodeSPQRRotation.h:88
ogdf::sync_plan
Definition: clustering.h:44
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:54
ogdf::sync_plan::NodeSPQRRotation::RigidEmbedding
Definition: NodeSPQRRotation.h:73
IntrusiveList.h
An intrusive list for the leaves of a PCTree. TODO should be moved to a central location; merge with ...
ogdf::sync_plan::NodeSPQRRotation::children
NodeArray< SList< node > > children
Definition: NodeSPQRRotation.h:65
ogdf::BCTree::auxiliaryGraph
const Graph & auxiliaryGraph() const
Returns the biconnected components graph.
Definition: BCTree.h:423
ogdf::pc_tree::NodePCRotation
This class represents the embedding tree of a single node in a biconnected component.
Definition: NodePCRotation.h:44
ogdf::sync_plan::NodeSPQRRotation
Derive embedding trees from an DynamicSPQRForest. Warning: breaks on certain parallel edge configurat...
Definition: NodeSPQRRotation.h:57
ogdf::AdjElement
Class for adjacency list elements.
Definition: Graph_d.h:135
ogdf::sync_plan::NodeSPQRRotation::RigidEmbedding::rigids
NodeArray< GraphCopySimple * > rigids
Definition: NodeSPQRRotation.h:76
ogdf::pc_tree::FilteringPCTreeWalk
A DFS or BFS through a PCTree.
Definition: PCTreeIterators.h:123
ogdf::edge
EdgeElement * edge
The type of edges.
Definition: Graph_d.h:67
ogdf::DynamicSPQRForest::spqrproper
node spqrproper(edge eH) const
Definition: DynamicSPQRForest.h:338
ogdf::AdjElement::theEdge
edge theEdge() const
Returns the edge associated with this adjacency entry.
Definition: Graph_d.h:153
ogdf::sync_plan::NodeSPQRRotation::rigids
const NodeArray< GraphCopySimple * > & rigids
Definition: NodeSPQRRotation.h:62
BCTree.h
Declaration of class BCTree.
ogdf::Graph::nodes
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
Definition: Graph_d.h:924
ogdf::sync_plan::NodeSPQRRotation::RigidEmbedding::spqr
const DynamicSPQRForest spqr
Definition: NodeSPQRRotation.h:75
ogdf::NodeElement::degree
int degree() const
Returns the degree of the node (indegree + outdegree).
Definition: Graph_d.h:276
ogdf::DynamicSPQRForest::spqrroot
node spqrroot(node vB) const
Returns the root of the SPQR-tree for a given B-component of the BC-tree.
Definition: DynamicSPQRForest.h:364
GraphList.h
Decralation of GraphElement and GraphList classes.
ogdf::DynamicBCTree::bccomp
node bccomp(node vH) const override
ogdf::sync_plan::NodeSPQRRotation::mapGraph
void mapGraph(const Graph *G, const std::function< node(node)> &node_map, const std::function< edge(edge)> &edge_map)
Definition: NodeSPQRRotation.h:121
DynamicSPQRForest.h
Declaration of class DynamicSPQRForest.
PCRegistry.h
A registry that allows labelling the nodes of a PC-tree.
ogdf::DynamicSPQRForest
Dynamic SPQR-forest.
Definition: DynamicSPQRForest.h:49
ogdf::node
NodeElement * node
The type of nodes.
Definition: Graph_d.h:63
GraphCopy.h
Declaration of graph copy classes.
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:651
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:862
NodePCRotation.h
An embedding tree representing, for a single node, all orders of incident edges in all planar embeddi...
ogdf::BCTree::typeOfGNode
GNodeType typeOfGNode(node vG) const
Definition: BCTree.h:441
PCTreeIterators.h
Utils for PCTree::allNodes(), PCTree::innerNodes(), PCNode::children() and PCNode::neighbors().
ogdf::pc_tree::PCNode
A node in a PC-tree that is either a P-node, C-node or leaf.
Definition: PCNode.h:58
PCNode.h
A node in a PC-tree that is either a P-node, C-node or leaf.
basic.h
Basic declarations, included by all source files.
ogdf::sync_plan::NodeSPQRRotation::highest_with_edges
NodeArray< node > highest_with_edges
Definition: NodeSPQRRotation.h:63
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::sync_plan::NodeSPQRRotation::spqr
const DynamicSPQRForest & spqr
Definition: NodeSPQRRotation.h:59
ogdf::NodeElement::firstAdj
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
Definition: Graph_d.h:279
ogdf::sync_plan::NodeSPQRRotation::NodeSPQRRotation
NodeSPQRRotation(const DynamicSPQRForest &_spqr, node n, const NodeArray< GraphCopySimple * > &_rigids)
Definition: NodeSPQRRotation.h:90
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:356
ogdf::sync_plan::NodeSPQRRotation::RigidEmbedding::~RigidEmbedding
~RigidEmbedding()
Definition: NodeSPQRRotation.h:80
List.h
Declaration of doubly linked lists and iterators.
ogdf::NodeElement::graphOf
const Graph * graphOf() const
Returns the graph containing this node (debug only).
Definition: Graph_d.h:337
ogdf::sync_plan::NodeSPQRRotation::edges
NodeArray< SList< adjEntry > > edges
Definition: NodeSPQRRotation.h:64
ogdf::BCTree::GNodeType::Normal
@ Normal
an ordinary vertex, i.e. not a cut-vertex
ogdf::Logger
Centralized global and local logging facility working on streams like std::cout.
Definition: Logger.h:100
ogdf::DynamicSPQRForest::spqrTree
const Graph & spqrTree() const
Returns the SPQR-tree graph.
Definition: DynamicSPQRForest.h:394
ogdf::sync_plan::NodeSPQRRotation::apex
node apex
Definition: NodeSPQRRotation.h:60
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233