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>
39 
40 #include <iterator>
41 #include <utility>
42 
43 namespace ogdf {
44 
46 
54 class OGDF_EXPORT NodeSet : public RegisteredSet<internal::GraphNodeRegistry> {
55 public:
57  explicit NodeSet(const Graph& graph)
58  : RegisteredSet((const internal::GraphNodeRegistry&)graph) { }
59 
62 
64  const list_type& nodes() { return elements(); }
65 
67  const Graph& graphOf() const {
68  OGDF_ASSERT(registeredAt());
69  return *registeredAt()->graphOf();
70  }
71 };
72 
74 
86 class OGDF_EXPORT EdgeSet : public RegisteredSet<internal::GraphEdgeRegistry> {
87 public:
89  explicit EdgeSet(const Graph& graph)
90  : RegisteredSet((const internal::GraphEdgeRegistry&)graph) { }
91 
94 
96  const list_type& edges() { return elements(); }
97 
99  const Graph& graphOf() const {
101  return *registeredAt()->graphOf();
102  }
103 };
104 
106 
114 class OGDF_EXPORT AdjEntrySet : public RegisteredSet<internal::GraphAdjRegistry> {
115 public:
117  explicit AdjEntrySet(const Graph& graph)
118  : RegisteredSet((const internal::GraphAdjRegistry&)graph) { }
119 
122 
124  const list_type& adjEntries() { return elements(); }
125 
127  const Graph& graphOf() const {
129  return *registeredAt()->graphOf();
130  }
131 };
132 
133 template<OGDF_NODE_LIST NL>
134 std::pair<int, int> Graph::insert(const NL& nodeList, const EdgeSet& edgeSet,
135  NodeArray<node>& nodeMap, EdgeArray<edge>& edgeMap) {
136  using std::size;
137  m_regNodeArrays.reserveSpace(size(nodeList));
138  m_regEdgeArrays.reserveSpace(size(edgeSet));
139  m_regAdjArrays.reserveSpace(size(edgeSet));
140  using std::begin;
141  using std::end;
142  return insert(begin(nodeList), end(nodeList), edgeSet, nodeMap, edgeMap);
143 }
144 
145 }
ogdf::EdgeSet::edges
const list_type & edges()
Returns a reference to the list of edges contained in this set.
Definition: GraphSets.h:96
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::AdjEntrySet::graphOf
const Graph & graphOf() const
Returns the associated graph.
Definition: GraphSets.h:127
Graph.h
Includes declaration of graph class.
ogdf::EdgeSet::graphOf
const Graph & graphOf() const
Returns the associated graph.
Definition: GraphSets.h:99
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.
copy_move.h
Utility macros for declaring copy and move constructors and assignment operations.
ogdf::AdjEntrySet
AdjEntry sets.
Definition: GraphSets.h:114
ogdf::begin
HypergraphRegistry< HypernodeElement >::iterator begin(const HypergraphRegistry< HypernodeElement > &self)
ogdf::Graph::m_regEdgeArrays
internal::GraphEdgeRegistry m_regEdgeArrays
The registered edge arrays.
Definition: Graph_d.h:878
ogdf::NodeSet
Node sets.
Definition: GraphSets.h:54
ogdf::NodeSet::nodes
const list_type & nodes()
Returns a reference to the list of nodes contained in this set.
Definition: GraphSets.h:64
ogdf::EdgeSet::EdgeSet
EdgeSet(const Graph &graph)
Creates a new edge set associated with graph.
Definition: GraphSets.h:89
ogdf::internal::GraphEdgeRegistry
GraphRegistry< EdgeElement > GraphEdgeRegistry
Definition: Graph_d.h:639
ogdf::internal::GraphAdjRegistry
GraphRegistry< AdjElement, GraphAdjIterator, 2 > GraphAdjRegistry
Definition: Graph_d.h:640
ogdf::internal::GraphNodeRegistry
GraphRegistry< NodeElement > GraphNodeRegistry
Definition: Graph_d.h:638
ogdf::NodeSet::NodeSet
NodeSet(const Graph &graph)
Creates a new node set associated with graph.
Definition: GraphSets.h:57
GraphList.h
Decralation of GraphElement and GraphList classes.
ogdf::EdgeSet
Edge sets.
Definition: GraphSets.h:86
ogdf::NodeSet::graphOf
const Graph & graphOf() const
Returns the associated graph.
Definition: GraphSets.h:67
ogdf::List< element_type >
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:659
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:866
ogdf::AdjEntrySet::AdjEntrySet
AdjEntrySet(const Graph &graph)
Creates a new adjEntry set associated with graph.
Definition: GraphSets.h:117
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:102
basic.h
Basic declarations, included by all source files.
ogdf::RegisteredSet::registeredAt
const Registry * registeredAt() const
Returns the associated registry.
Definition: RegisteredSet.h:175
ogdf::end
HypergraphRegistry< HypernodeElement >::iterator end(const HypergraphRegistry< HypernodeElement > &self)
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition: config.h:117
ogdf::RegisteredSet::RegisteredSet
RegisteredSet()
Creates an empty set associated with no registry.
Definition: RegisteredSet.h:72
ogdf::Graph::m_regNodeArrays
internal::GraphNodeRegistry m_regNodeArrays
The registered node arrays.
Definition: Graph_d.h:877
OGDF_DEFAULT_COPY
#define OGDF_DEFAULT_COPY(cls)
Explicitly provides default copy construction and assignment for class cls.
Definition: copy_move.h:47
ogdf::Graph::m_regAdjArrays
internal::GraphAdjRegistry m_regAdjArrays
The registered adjEntry arrays.
Definition: Graph_d.h:879
ogdf::AdjEntrySet::adjEntries
const list_type & adjEntries()
Returns a reference to the list of adjEntries contained in this set.
Definition: GraphSets.h:124
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:717
ogdf::RegistryBase::reserveSpace
void reserveSpace(int new_keys)
Resizes all arrays to make space of new_keys new keys.
Definition: RegisteredArray.h:249