Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
QPartitioning.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>
36
37namespace ogdf::sync_plan {
38class QPartitioning; // IWYU pragma: keep
39
40#define OGDF_DECL_REG_ARRAY_TYPE(v, c) RegisteredArray<QPartitioning, v, c>
43#undef OGDF_DECL_REG_ARRAY_TYPE
44
47 public RegistryBase<int, QPartitioning, int> {
48private:
51 int q_vertex_count = 0;
52 int partition_next_id = 0;
53
54public:
55 static inline int NO_PARTITION = -1;
56
57 explicit QPartitioning(const Graph* G) : GraphObserver(), partitions(*G, NO_PARTITION) {
58 partitioned_nodes.init(*this);
59 reregister(G);
60 }
61
62 bool isQVertex(node n) const;
63
64 int getPartitionOf(node n) const;
65
68 int makeQVertex(node n, int p = NO_PARTITION);
69
71
72 int partitionCount() const { return partition_next_id; }
73
74 int qVertexCount() const { return q_vertex_count; }
75
76 const List<node>& nodesInPartition(int partition) const { return partitioned_nodes[partition]; }
77
79 static inline int keyToIndex(int key) { return key; }
80
82 bool isKeyAssociated(int key) const { return 0 <= key && key <= maxKeyIndex(); }
83
85 int maxKeyIndex() const { return partition_next_id - 1; }
86
88 int calculateArraySize(int add) const { return calculateTableSize(partition_next_id + add); }
89
90 int begin() const { return 0; }
91
92 int end() const { return partition_next_id; }
93
94protected:
95 void nodeDeleted(node v) override;
96
97 void nodeAdded(node v) override {};
98
99 void edgeDeleted(edge e) override {};
100
101 void edgeAdded(edge e) override {};
102
103 void cleared() override {
104 partitioned_nodes.fillWithDefault();
105 partitions.fill(NO_PARTITION);
106 q_vertex_count = 0;
107 partition_next_id = 0;
108 };
109};
110}
Includes declaration of graph class.
Declaration of doubly linked lists and iterators.
#define OGDF_DECL_REG_ARRAY(NAME)
Basic declarations, included by all source files.
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
Class for the representation of nodes.
Definition Graph_d.h:241
Dynamic arrays indexed with arbitrary keys.
void init(const Base *base=nullptr)
Reinitializes the array. Associates the array with the matching registry of base.
Abstract base class for registries.
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition Graph_d.h:659
Manages the partitioning of Q-nodes in an instance of SyncPlan.
int maxKeyIndex() const
Returns the maximum index of all keys managed by this registry.
PartitionArray< List< node > > partitioned_nodes
const List< node > & nodesInPartition(int partition) const
void edgeAdded(edge e) override
Called by watched graph after an edge has been added.
void nodeAdded(node v) override
Called by watched graph after a node has been added.
int getPartitionOf(node n) const
void cleared() override
Called by watched graph when its clear function is called, just before things are removed.
int makeQVertex(node n, int p=NO_PARTITION)
Mark a node as Q-node.
void nodeDeleted(node v) override
Called by watched graph just before a node is deleted.
bool isQVertex(node n) const
bool isKeyAssociated(int key) const
Returns whether key is associated with this registry.
static int keyToIndex(int key)
Returns the index of key.
int calculateArraySize(int add) const
Returns the array size currently requested by this registry.
void edgeDeleted(edge e) override
Called by watched graph just before an edge is deleted.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
int calculateTableSize(int actualCount)
The default growth function for registered arrays.