|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
44 #include <type_traits>
50 template<
class T,
class =
void>
54 struct is_iterator<T,
std::void_t<typename std::iterator_traits<T>::iterator_category>>
57 template<
typename Iterator>
58 typename std::enable_if<!is_iterator<Iterator>::value,
size_t>
::type guess_dist(Iterator, Iterator) {
62 template<
typename Iterator>
63 typename std::enable_if<is_iterator<Iterator>::value,
64 typename std::iterator_traits<Iterator>::difference_type>
::type
66 if constexpr (std::is_same<
typename std::iterator_traits<Iterator>::iterator_category,
67 std::random_access_iterator_tag>::value) {
75 template<OGDF_NODE_ITER NI,
bool notifyObservers,
bool copyIDs>
77 int& newNodes,
void* cbData) {
79 if (guessedNodes > 0 && notifyObservers) {
83 for (
auto it = nodesBegin; it != nodesEnd; ++it) {
91 if (notifyObservers) {
101 template<OGDF_NODE_ITER NI, OGDF_EDGE_ITER EI,
bool copyEmbedding,
bool copyIDs,
bool notifyObservers>
102 std::pair<int, int>
Graph::insert(
const NI& nodesBegin,
const NI& nodesEnd,
const EI& edgesBegin,
107 int newNodes = 0, newEdges = 0;
109 &newNodes, &newEdges);
110 if (nodesBegin == nodesEnd) {
112 return {newNodes, newEdges};
114 insertNodes<NI, notifyObservers, copyIDs>(nodesBegin, nodesEnd, nodeMap, newNodes, cbData);
116 if (edgesBegin == edgesEnd) {
118 return {newNodes, newEdges};
123 if (guessedEdges > 0) {
129 for (
auto it = edgesBegin; it != edgesEnd; ++it) {
133 if (src ==
nullptr || tgt ==
nullptr) {
145 if (notifyObservers) {
157 #ifdef OGDF_HEAVY_DEBUG
161 return {newNodes, newEdges};
164 for (
auto it = nodesBegin; it != nodesEnd; ++it) {
166 node v = nodeMap[vG];
169 edge e = edgeMap[eG];
177 if (adj->
succ() !=
nullptr || adj->
pred() !=
nullptr || v->
adjEntries.head() == adj) {
185 if (notifyObservers) {
189 for (
auto it = edgesBegin; it != edgesEnd; ++it) {
191 edge e = edgeMap[eG];
192 if (nodeMap[eG->
source()] ==
nullptr || nodeMap[eG->
target()] ==
nullptr) {
205 #ifdef OGDF_HEAVY_DEBUG
210 return {newNodes, newEdges};
213 template<OGDF_NODE_ITER NI, OGDF_EDGE_FILTER EF,
bool copyIDs,
bool notifyObservers>
214 std::pair<int, int>
Graph::insert(
const NI& nodesBegin,
const NI& nodesEnd,
const EF& edgeFilter,
219 int newNodes = 0, newEdges = 0;
221 preInsert(
true, copyIDs, notifyObservers,
true, nodeMap, edgeMap, &newNodes, &newEdges);
222 if (nodesBegin == nodesEnd) {
224 return {newNodes, newEdges};
226 insertNodes<NI, notifyObservers, copyIDs>(nodesBegin, nodesEnd, nodeMap, newNodes, cbData);
228 for (
auto it = nodesBegin; it != nodesEnd; ++it) {
230 node v = nodeMap[vG];
233 if (!edgeFilter(eG)) {
237 edge e = edgeMap[eG];
241 if (twin ==
nullptr) {
263 if (adj->
succ() ==
nullptr && adj->
pred() ==
nullptr && v->
adjEntries.head() != adj) {
272 if (notifyObservers) {
276 for (
auto it = nodesBegin; it != nodesEnd; ++it) {
283 edge e = edgeMap[eG];
298 #ifdef OGDF_HEAVY_DEBUG
303 return {newNodes, newEdges};
The namespace for all OGDF objects.
Includes declaration of graph class.
node pureNewNode(int index)
Creates a new node object with id index and adds it to the list of nodes.
adjEntry pred() const
Returns the predecessor in the adjacency list.
edge pureNewEdge(node src, node tgt, int index)
Creates a new edge object with id index and corresponding AdjElements and adds it to the list of edge...
Graph * graphOf() const
Returns a pointer to the associated graph.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
HypergraphRegistry< HypernodeElement >::iterator begin(const HypergraphRegistry< HypernodeElement > &self)
int index() const
Returns the (unique) node index.
internal::GraphEdgeRegistry m_regEdgeArrays
The registered edge arrays.
int index() const
Returns the index of the edge.
void insertNodes(const NI &nodesBegin, const NI &nodesEnd, NodeArray< node, true > &nodeMap, int &newNodes, void *cbData)
virtual void postInsert(void *userData, int newNodes, int newEdges)
Callback notifying subclasses that an insert() call has finished.
virtual void nodeInserted(void *userData, node original, node copy)
Callback notifying subclasses that insert() copied a node.
Class for adjacency list elements.
bool isSource() const
Returns true iff this is the source adjacency entry of the corresponding edge.
std::enable_if<!is_iterator< Iterator >::value, size_t >::type guess_dist(Iterator, Iterator)
edge theEdge() const
Returns the edge associated with this adjacency entry.
AdjElement * m_adjTgt
Corresponding adjacency entry at target node.
const ListPure< GraphObserver * > & getObservers() const
int m_edgeIdCount
The Index that will be assigned to the next created edge.
Decralation of GraphElement and GraphList classes.
adjEntry succ() const
Returns the successor in the adjacency list.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
void consistencyCheck() const
Asserts that this graph is consistent.
node source() const
Returns the source node of the edge.
Abstract Base class for graph observers.
RegisteredArray for nodes, edges and adjEntries of a graph.
void keyAdded(Key key)
Records the addition of a new key and resizes all registered arrays if necessary.
adjEntry adjSource() const
Returns the corresponding adjacancy entry at source node.
virtual void * preInsert(bool copyEmbedding, bool copyIDs, bool notifyObservers, bool edgeFilter, NodeArray< node > &nodeMap, EdgeArray< edge > &edgeMap, int *newNodes, int *newEdges)
Callback notifying subclasses that some graph is about to be insert() -ed.
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
Decralation of graph iterators.
int m_nodeIdCount
The Index that will be assigned to the next created node.
adjEntry adjTarget() const
Returns the corresponding adjacancy entry at target node.
AdjElement * m_adjSrc
Corresponding adjacency entry at source node.
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.
Basic declarations, included by all source files.
HypergraphRegistry< HypernodeElement >::iterator end(const HypergraphRegistry< HypernodeElement > &self)
internal::GraphNodeRegistry m_regNodeArrays
The registered node arrays.
Class for the representation of edges.
Declaration of doubly linked lists and iterators.
virtual void edgeInserted(void *userData, edge original, edge copy)
Callback notifying subclasses that insert() copied an edge.
node target() const
Returns the target node of the edge.
void copyEmbedding(const Graph &from, Graph &to, std::function< adjEntry(adjEntry)> adjMapFromTo)
Class for the representation of nodes.
internal::GraphAdjRegistry m_regAdjArrays
The registered adjEntry arrays.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
void reserveSpace(int new_keys)
Resizes all arrays to make space of new_keys new keys.