Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

GraphSets.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/Graph_d.h>
36 
37 namespace ogdf {
38 
40 
51 template<bool SupportFastSizeQuery = true>
52 class NodeSet : public RegisteredSet<internal::GraphNodeRegistry, SupportFastSizeQuery> {
54 
55 public:
56  using RS::RS;
57 
59  explicit NodeSet(const Graph& graph) : RS((const internal::GraphNodeRegistry&)graph) {};
60 
62  explicit NodeSet() = default;
63 
65  const typename RS::list_type& nodes() { return RS::elements(); }
66 
68  const Graph& graphOf() const {
70  return *RS::registeredAt();
71  }
72 };
73 
75 
86 template<bool SupportFastSizeQuery = true>
87 class EdgeSet : public RegisteredSet<internal::GraphEdgeRegistry, SupportFastSizeQuery> {
89 
90 public:
91  using RS::RS;
92 
94  explicit EdgeSet(const Graph& graph) : RS((const internal::GraphEdgeRegistry&)graph) {};
95 
97  explicit EdgeSet() = default;
98 
100  const typename RS::list_type& edges() { return RS::elements(); }
101 
103  const Graph& graphOf() const {
105  return *RS::registeredAt();
106  }
107 };
108 
110 
121 template<bool SupportFastSizeQuery = true>
122 class AdjEntrySet : public RegisteredSet<internal::GraphAdjRegistry, SupportFastSizeQuery> {
124 
125 public:
126  using RS::RS;
127 
129  explicit AdjEntrySet(const Graph& graph) : RS((const internal::GraphAdjRegistry&)graph) {};
130 
132  explicit AdjEntrySet() = default;
133 
135  const typename RS::list_type& adjEntries() { return RS::elements(); }
136 
138  const Graph& graphOf() const {
140  return *RS::registeredAt();
141  }
142 };
143 
144 template<OGDF_NODE_LIST NL>
145 std::pair<int, int> Graph::insert(const NL& nodeList, const EdgeSet<true>& edgeSet,
146  NodeArray<node>& nodeMap, EdgeArray<edge>& edgeMap) {
147  using std::size;
148  m_regNodeArrays.reserveSpace(size(nodeList));
149  m_regEdgeArrays.reserveSpace(size(edgeSet));
150  m_regAdjArrays.reserveSpace(size(edgeSet));
151  using std::begin;
152  using std::end;
153  return insert(begin(nodeList), end(nodeList), edgeSet, nodeMap, edgeMap);
154 }
155 
156 template<OGDF_NODE_LIST NL>
157 std::pair<int, int> Graph::insert(const NL& nodeList, const EdgeSet<false>& edgeSet,
158  NodeArray<node>& nodeMap, EdgeArray<edge>& edgeMap) {
159  using std::size;
160  m_regNodeArrays.reserveSpace(size(nodeList));
161  using std::begin;
162  using std::end;
163  return insert(begin(nodeList), end(nodeList), edgeSet, nodeMap, edgeMap);
164 }
165 
166 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::RegisteredSet< internal::GraphNodeRegistry, SupportFastSizeQuery >::elements
const list_type & elements() const
Returns a reference to the list of elements contained in this set.
Definition: RegisteredSet.h:142
ogdf::NodeSet::NodeSet
NodeSet()=default
Creates an empty node set associated with no graph.
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:54
RegisteredSet.h
Declaration and implementation of ogdf::RegisteredSet.
ogdf::AdjEntrySet
AdjEntry sets.
Definition: GraphSets.h:122
ogdf::begin
HypergraphRegistry< HypernodeElement >::iterator begin(const HypergraphRegistry< HypernodeElement > &self)
ogdf::AdjEntrySet::graphOf
const Graph & graphOf() const
Returns the associated graph.
Definition: GraphSets.h:138
ogdf::Graph::m_regEdgeArrays
internal::GraphEdgeRegistry m_regEdgeArrays
The registered edge arrays.
Definition: Graph_d.h:873
ogdf::NodeSet::nodes
const RS::list_type & nodes()
Returns a reference to the list of nodes contained in this set.
Definition: GraphSets.h:65
ogdf::NodeSet
Node sets.
Definition: GraphSets.h:52
ogdf::RegisteredSet< internal::GraphNodeRegistry, SupportFastSizeQuery >::list_type
typename std::conditional< SupportFastSizeQuery, List< element_type >, ListPure< element_type > >::type list_type
Definition: RegisteredSet.h:57
ogdf::RegisteredSet< internal::GraphNodeRegistry, SupportFastSizeQuery >::registeredAt
const internal::GraphNodeRegistry * registeredAt() const
Returns the associated registry.
Definition: RegisteredSet.h:145
ogdf::NodeSet::graphOf
const Graph & graphOf() const
Returns the associated graph.
Definition: GraphSets.h:68
ogdf::internal::GraphEdgeRegistry
GraphRegistry< EdgeElement > GraphEdgeRegistry
Definition: Graph_d.h:631
ogdf::internal::GraphAdjRegistry
GraphRegistry< AdjElement, GraphAdjIterator, 2 > GraphAdjRegistry
Definition: Graph_d.h:632
ogdf::internal::GraphNodeRegistry
GraphRegistry< NodeElement > GraphNodeRegistry
Definition: Graph_d.h:630
ogdf::EdgeSet
Edge sets.
Definition: Graph_d.h:748
ogdf::AdjEntrySet::adjEntries
const RS::list_type & adjEntries()
Returns a reference to the list of adjEntries contained in this set.
Definition: GraphSets.h:135
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
ogdf::RegisteredSet
Constant-time set operations.
Definition: RegisteredSet.h:53
ogdf::Graph::insert
std::pair< int, int > insert(const NI &nodesBegin, const NI &nodesEnd, const EI &edgesBegin, const EI &edgesEnd, NodeArray< node > &nodeMap, EdgeArray< edge > &edgeMap)
Inserts a copy of a given subgraph into this graph.
Definition: InducedSubgraph.h:93
ogdf::AdjEntrySet::AdjEntrySet
AdjEntrySet()=default
Creates an empty adjEntry set associated with no graph.
ogdf::end
HypergraphRegistry< HypernodeElement >::iterator end(const HypergraphRegistry< HypernodeElement > &self)
ogdf::NodeSet::NodeSet
NodeSet(const Graph &graph)
Creates a new node set associated with graph.
Definition: GraphSets.h:59
ogdf::Graph::m_regNodeArrays
internal::GraphNodeRegistry m_regNodeArrays
The registered node arrays.
Definition: Graph_d.h:872
ogdf::EdgeSet::EdgeSet
EdgeSet(const Graph &graph)
Creates a new edge set associated with graph.
Definition: GraphSets.h:94
ogdf::EdgeSet::graphOf
const Graph & graphOf() const
Returns the associated graph.
Definition: GraphSets.h:103
ogdf::AdjEntrySet::AdjEntrySet
AdjEntrySet(const Graph &graph)
Creates a new adjEntry set associated with graph.
Definition: GraphSets.h:129
Graph_d.h
Pure declaration header, find template implementation in Graph.h.
ogdf::EdgeSet::EdgeSet
EdgeSet()=default
Creates an empty edge set associated with no graph.
ogdf::EdgeSet::edges
const RS::list_type & edges()
Returns a reference to the list of edges contained in this set.
Definition: GraphSets.h:100
ogdf::Graph::m_regAdjArrays
internal::GraphAdjRegistry m_regAdjArrays
The registered adjEntry arrays.
Definition: Graph_d.h:874
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:709
ogdf::RegistryBase::reserveSpace
void reserveSpace(int new_keys)
Resizes all arrays to make space of new_keys new keys.
Definition: RegisteredArray.h:197