Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
PMatching.h
Go to the documentation of this file.
1
31#pragma once
32
33#include <ogdf/basic/Graph.h>
34#include <ogdf/basic/List.h>
35#include <ogdf/basic/basic.h>
37
38#include <functional>
39#include <memory>
40#include <ostream>
41#include <utility>
42
43namespace ogdf::sync_plan {
45
48 node node1, node2;
49 int pipe_priority = -1;
51 void* heap_entry = nullptr;
52 int heap_data = 0;
53#ifdef OGDF_DEBUG
55#endif
56
57 Pipe(node node1, node node2);
58
59 int degree() const;
60
61 node getTwin(node n) const;
62
63 friend std::ostream& operator<<(std::ostream& os, const Pipe& pipe);
64};
65
68 virtual ~PipeQueue() = default;
69
70 virtual bool empty() = 0;
71
72 virtual int size() = 0;
73
74 virtual Pipe* getTop() = 0;
75
76 virtual void addPipe(Pipe* p) = 0;
77
78 virtual void removePipe(Pipe* p) = 0;
79
80 virtual void rebuild(List<Pipe>& pipes_list) = 0;
81
82 virtual void clear() = 0;
83};
84
87 friend class SyncPlanConsistency;
88
89private:
90 int priority_pipes = 0;
93 std::unique_ptr<PipeQueue> queue;
94
95public:
96 explicit PMatching(const Graph* G) : GraphObserver(), nodes(*G, nullptr) { reregister(G); }
97
98 bool isMatchedPVertex(node n) const;
99
101 node getTwin(node n) const;
102
104
105 const Pipe* getPipe(node n) const;
106
107 const Pipe& getTopPipe() const;
108
110
112
113 const List<Pipe>& getPipes() const;
114
115 int getPipeCount() const;
116
118 bool isReduced() const;
119
122
124
126
128
130
131 std::function<std::ostream&(std::ostream&)> printBijection(node u) const;
132
133 void matchNodes(node f, node s);
134
135 node removeMatching(node n, node t = nullptr);
136
139
140 int getPriorityPipeCount() const { return priority_pipes; }
141
144
146 queue.reset(q);
147 rebuildHeap();
148 }
149
150 void setPipeQueue(std::unique_ptr<PipeQueue> q) {
151 queue = std::move(q);
152 rebuildHeap();
153 }
154
155 PipeQueue* getPipeQueue() const { return queue.get(); }
156
157protected:
158 void nodeDeleted(node v) override;
159
160 void nodeAdded(node v) override {};
161
162 void edgeDeleted(edge e) override {};
163
164 void edgeAdded(edge e) override {};
165
166 void cleared() override {
167 pipes_list.clear();
168 if (queue) {
169 queue->clear();
170 }
171 nodes.fill(nullptr);
172 };
173};
174}
Utilities for working with the bijections between the edges incident to the two endpoints of a Pipe.
Includes declaration of graph class.
Declaration of doubly linked lists and iterators.
Basic declarations, included by all source files.
Class for adjacency list elements.
Definition Graph_d.h:143
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
Abstract Base class for graph observers.
Definition Graph_d.h:775
Doubly linked lists (maintaining the length of the list).
Definition List.h:1451
void clear()
Removes all elements from the list.
Definition List.h:1626
Encapsulates a pointer to a list element.
Definition List.h:113
Class for the representation of nodes.
Definition Graph_d.h:241
Simple before-C++20 version for std::ranges::ref_view.
Definition Iterators.h:41
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition Graph_d.h:717
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition Graph_d.h:659
Manages the matching of P-nodes via pipes in an instance of SyncPlan.
Definition PMatching.h:86
void nodeDeleted(node v) override
Called by watched graph just before a node is deleted.
node removeMatching(node n, node t=nullptr)
void setPipeQueue(PipeQueue *q)
Definition PMatching.h:145
void cleared() override
Called by watched graph when its clear function is called, just before things are removed.
Definition PMatching.h:166
void setPipeQueue(std::unique_ptr< PipeQueue > q)
Definition PMatching.h:150
void getIncidentEdgeBijection(node u, AdjEntryArray< adjEntry > &out) const
const Pipe * getPipe(node n) const
adjEntry translateIncidentEdge(adjEntry e) const
void edgeDeleted(edge e) override
Called by watched graph just before an edge is deleted.
Definition PMatching.h:162
void getIncidentEdgeBijection(node u, EdgeArray< edge > &out) const
const Pipe & getTopPipe() const
void nodeAdded(node v) override
Called by watched graph after a node has been added.
Definition PMatching.h:160
PMatching(const Graph *G)
Definition PMatching.h:96
PipeBijRange getIncidentEdgeBijection(node u) const
Get the bijection between the edges incident to the two endpoints of a pipe.
List< Pipe >::const_iterator begin() const
void edgeAdded(edge e) override
Called by watched graph after an edge has been added.
Definition PMatching.h:164
void makePriority(node n)
Mark the pipe of this ndoe to be processed before all other pipes, no matter the order in the PipeQue...
PipeQueue * getPipeQueue() const
Definition PMatching.h:155
node getTwin(node n) const
For a matched vertex, return the vertex it is matched with.
void rebuildHeap()
Rebuild the PipeQueue, e.g. after priorities were changed externally.
List< Pipe >::const_iterator end() const
std::unique_ptr< PipeQueue > queue
Definition PMatching.h:93
bool isReduced() const
Whether there are no pipes left.
std::function< std::ostream &(std::ostream &)> printBijection(node u) const
void getIncidentEdgeBijection(node u, PipeBij &out) const
const List< Pipe > & getPipes() const
void matchNodes(node f, node s)
NodeArray< Pipe * > nodes
Definition PMatching.h:92
int getPriorityPipeCount() const
Definition PMatching.h:140
node getTwinOrNull(node n) const
bool isMatchedPVertex(node n) const
Consistency checks for debugging the SyncPlan algorithm.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
A pair of matched vertices of the same degree, whose rotation shall be synchronized.
Definition PMatching.h:47
node getTwin(node n) const
List< Pipe >::iterator list_entry
Definition PMatching.h:50
Pipe(node node1, node node2)
friend std::ostream & operator<<(std::ostream &os, const Pipe &pipe)
A queue of all pipes, ordered by an arbitrary comparator function.
Definition PMatching.h:67
virtual void rebuild(List< Pipe > &pipes_list)=0
virtual void clear()=0
virtual ~PipeQueue()=default
virtual bool empty()=0
virtual Pipe * getTop()=0
virtual void removePipe(Pipe *p)=0
virtual void addPipe(Pipe *p)=0