Loading [MathJax]/extensions/tex2jax.js

Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
NodeSet.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/List.h>
36
37namespace ogdf {
38
40
53template<bool SupportFastSizeQuery = true>
54class NodeSet {
55public:
56 using ListType =
57 typename std::conditional<SupportFastSizeQuery, List<node>, ListPure<node>>::type;
58
60 explicit NodeSet(const Graph& G) : m_it(G) { }
61
63
69 void insert(node v) {
70 OGDF_ASSERT(v->graphOf() == m_it.graphOf());
72
73 if (!itV.valid()) {
74 itV = m_nodes.pushBack(v);
75 }
76 }
77
79
85 void remove(node v) {
86 OGDF_ASSERT(v->graphOf() == m_it.graphOf());
88
89 if (itV.valid()) {
90 m_nodes.del(itV);
92 }
93 }
94
96
100 void clear() {
101 m_it.init(graphOf());
102 m_nodes.clear();
103 }
104
106
111 bool isMember(node v) const {
112 OGDF_ASSERT(v->graphOf() == m_it.graphOf());
113 return m_it[v].valid();
114 }
115
117 const ListType& nodes() const { return m_nodes; }
118
120 const Graph& graphOf() const { return *m_it.graphOf(); }
121
123
126 int size() const { return m_nodes.size(); }
127
129 template<bool OtherSupportsFastSizeQuery>
133
135 template<bool OtherSupportsFastSizeQuery>
137 m_nodes.clear();
138 m_it.init(other.graphOf());
139 for (node v : other.nodes()) {
140 insert(v);
141 }
142 }
143
144private:
148
151};
152
153}
Declaration of doubly linked lists and iterators.
Declaration and implementation of NodeArray class.
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:521
Encapsulates a pointer to a list element.
Definition List.h:103
Doubly linked lists.
Definition List.h:217
Dynamic arrays indexed with nodes.
Definition NodeArray.h:125
Class for the representation of nodes.
Definition Graph_d.h:177
Node sets.
Definition NodeSet.h:54
const Graph & graphOf() const
Returns the associated graph.
Definition NodeSet.h:120
void remove(node v)
Removes node v from this set.
Definition NodeSet.h:85
const ListType & nodes() const
Returns a reference to the list of nodes contained in this set.
Definition NodeSet.h:117
ListType m_nodes
The list of nodes contained in this set.
Definition NodeSet.h:150
NodeSet(const Graph &G)
Creates an empty node set associated with graph G.
Definition NodeSet.h:60
typename std::conditional< SupportFastSizeQuery, List< node >, ListPure< node > >::type ListType
Definition NodeSet.h:57
bool isMember(node v) const
Returns true iff node v is contained in this set.
Definition NodeSet.h:111
int size() const
Returns the number of nodes in this set.
Definition NodeSet.h:126
NodeArray< ListIterator< node > > m_it
m_it[v] contains the list iterator pointing to v if v is contained in this set, or an invalid list it...
Definition NodeSet.h:147
NodeSet & operator=(const NodeSet< OtherSupportsFastSizeQuery > &other)
Assignment operator.
Definition NodeSet.h:136
void clear()
Removes all nodes from this set.
Definition NodeSet.h:100
NodeSet(const NodeSet< OtherSupportsFastSizeQuery > &other)
Copy constructor.
Definition NodeSet.h:130
void insert(node v)
Inserts node v into this set.
Definition NodeSet.h:69
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:41
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.