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.h>
35 #include <ogdf/basic/GraphList.h> // IWYU pragma: keep
37 #include <ogdf/basic/basic.h>
38 
39 #include <iterator>
40 #include <utility>
41 
42 namespace ogdf {
43 
45 
56 template<bool SupportFastSizeQuery = true>
57 class NodeSet : public RegisteredSet<internal::GraphNodeRegistry, SupportFastSizeQuery> {
59 
60 public:
61  using RS::RS;
62 
64  explicit NodeSet(const Graph& graph) : RS((const internal::GraphNodeRegistry&)graph) {};
65 
67  explicit NodeSet() = default;
68 
70  const typename RS::list_type& nodes() { return RS::elements(); }
71 
73  const Graph& graphOf() const {
75  return *RS::registeredAt();
76  }
77 };
78 
80 
91 template<bool SupportFastSizeQuery = true>
92 class EdgeSet : public RegisteredSet<internal::GraphEdgeRegistry, SupportFastSizeQuery> {
94 
95 public:
96  using RS::RS;
97 
99  explicit EdgeSet(const Graph& graph) : RS((const internal::GraphEdgeRegistry&)graph) {};
100 
102  explicit EdgeSet() = default;
103 
105  const typename RS::list_type& edges() { return RS::elements(); }
106 
108  const Graph& graphOf() const {
110  return *RS::registeredAt();
111  }
112 };
113 
115 
126 template<bool SupportFastSizeQuery = true>
127 class AdjEntrySet : public RegisteredSet<internal::GraphAdjRegistry, SupportFastSizeQuery> {
129 
130 public:
131  using RS::RS;
132 
134  explicit AdjEntrySet(const Graph& graph) : RS((const internal::GraphAdjRegistry&)graph) {};
135 
137  explicit AdjEntrySet() = default;
138 
140  const typename RS::list_type& adjEntries() { return RS::elements(); }
141 
143  const Graph& graphOf() const {
145  return *RS::registeredAt();
146  }
147 };
148 
149 template<OGDF_NODE_LIST NL>
150 std::pair<int, int> Graph::insert(const NL& nodeList, const EdgeSet<true>& edgeSet,
151  NodeArray<node>& nodeMap, EdgeArray<edge>& edgeMap) {
152  using std::size;
153  m_regNodeArrays.reserveSpace(size(nodeList));
154  m_regEdgeArrays.reserveSpace(size(edgeSet));
155  m_regAdjArrays.reserveSpace(size(edgeSet));
156  using std::begin;
157  using std::end;
158  return insert(begin(nodeList), end(nodeList), edgeSet, nodeMap, edgeMap);
159 }
160 
161 template<OGDF_NODE_LIST NL>
162 std::pair<int, int> Graph::insert(const NL& nodeList, const EdgeSet<false>& edgeSet,
163  NodeArray<node>& nodeMap, EdgeArray<edge>& edgeMap) {
164  using std::size;
165  m_regNodeArrays.reserveSpace(size(nodeList));
166  using std::begin;
167  using std::end;
168  return insert(begin(nodeList), end(nodeList), edgeSet, nodeMap, edgeMap);
169 }
170 
171 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
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:144
Graph.h
Includes declaration of graph class.
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:66
RegisteredSet.h
Declaration and implementation of ogdf::RegisteredSet.
ogdf::AdjEntrySet
AdjEntry sets.
Definition: GraphSets.h:127
ogdf::begin
HypergraphRegistry< HypernodeElement >::iterator begin(const HypergraphRegistry< HypernodeElement > &self)
ogdf::AdjEntrySet::graphOf
const Graph & graphOf() const
Returns the associated graph.
Definition: GraphSets.h:143
ogdf::Graph::m_regEdgeArrays
internal::GraphEdgeRegistry m_regEdgeArrays
The registered edge arrays.
Definition: Graph_d.h:881
ogdf::NodeSet::nodes
const RS::list_type & nodes()
Returns a reference to the list of nodes contained in this set.
Definition: GraphSets.h:70
ogdf::NodeSet
Node sets.
Definition: GraphSets.h:57
ogdf::RegisteredSet< internal::GraphNodeRegistry, SupportFastSizeQuery >::list_type
typename std::conditional< SupportFastSizeQuery, List< element_type >, ListPure< element_type > >::type list_type
Definition: RegisteredSet.h:59
ogdf::RegisteredSet< internal::GraphNodeRegistry, SupportFastSizeQuery >::registeredAt
const internal::GraphNodeRegistry * registeredAt() const
Returns the associated registry.
Definition: RegisteredSet.h:147
ogdf::NodeSet::graphOf
const Graph & graphOf() const
Returns the associated graph.
Definition: GraphSets.h:73
ogdf::internal::GraphEdgeRegistry
GraphRegistry< EdgeElement > GraphEdgeRegistry
Definition: Graph_d.h:638
ogdf::internal::GraphAdjRegistry
GraphRegistry< AdjElement, GraphAdjIterator, 2 > GraphAdjRegistry
Definition: Graph_d.h:639
ogdf::internal::GraphNodeRegistry
GraphRegistry< NodeElement > GraphNodeRegistry
Definition: Graph_d.h:637
GraphList.h
Decralation of GraphElement and GraphList classes.
ogdf::EdgeSet
Edge sets.
Definition: Graph_d.h:755
ogdf::AdjEntrySet::adjEntries
const RS::list_type & adjEntries()
Returns a reference to the list of adjEntries contained in this set.
Definition: GraphSets.h:140
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::RegisteredSet
Constant-time set operations.
Definition: RegisteredSet.h:55
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:102
basic.h
Basic declarations, included by all source files.
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:64
ogdf::Graph::m_regNodeArrays
internal::GraphNodeRegistry m_regNodeArrays
The registered node arrays.
Definition: Graph_d.h:880
ogdf::EdgeSet::EdgeSet
EdgeSet(const Graph &graph)
Creates a new edge set associated with graph.
Definition: GraphSets.h:99
ogdf::EdgeSet::graphOf
const Graph & graphOf() const
Returns the associated graph.
Definition: GraphSets.h:108
ogdf::AdjEntrySet::AdjEntrySet
AdjEntrySet(const Graph &graph)
Creates a new adjEntry set associated with graph.
Definition: GraphSets.h:134
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:105
ogdf::Graph::m_regAdjArrays
internal::GraphAdjRegistry m_regAdjArrays
The registered adjEntry arrays.
Definition: Graph_d.h:882
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:716
ogdf::RegistryBase::reserveSpace
void reserveSpace(int new_keys)
Resizes all arrays to make space of new_keys new keys.
Definition: RegisteredArray.h:206