Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

ogdf_iterator.h
Go to the documentation of this file.
1 
31 #pragma once
32 
33 #include <ogdf/basic/Graph_d.h>
34 
35 namespace ogdf {
36 namespace internal {
37 namespace gcm {
38 namespace graph {
39 
42 template<typename _Entry>
44 public:
45  using Entry = _Entry;
47 
48 protected:
50 
51 public:
52  OGDFEntryIterator(Entry _cur) : m_cur(_cur) {
53  //nothing to do
54  }
55 
57  m_cur = m_cur->pred();
58  return *this;
59  }
60 
62  m_cur = m_cur->succ();
63  return *this;
64  }
65 
66  bool operator==(const Iterator& b) const { return m_cur == b.m_cur; }
67 
68  bool operator!=(const Iterator& b) const { return m_cur != b.m_cur; }
69 };
70 
71 template<typename Entry>
72 class EntryIterator : public OGDFEntryIterator<Entry> {
73 private:
75 
76 public:
77  using T = Entry;
78  using parent::parent;
79 
80  Entry operator*() { return this->m_cur; }
81 };
82 
84 class IncidentEdgeIterator : public OGDFEntryIterator<adjEntry> {
85 private:
87 
88 public:
89  using T = edge;
90  using parent::parent;
91 
92  edge operator*() { return this->m_cur->theEdge(); }
93 };
94 
95 /* Iterate over adjacent nodes
96  */
97 class AdjacentNodeIterator : public OGDFEntryIterator<adjEntry> {
98 private:
100 
101 public:
102  using T = node;
103  using parent::parent;
104 
105  node operator*() { return this->m_cur->twin()->theNode(); }
106 };
107 
111 
112 
113 }
114 }
115 }
116 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::internal::gcm::graph::AdjacentNodeIterator::operator*
node operator*()
Definition: ogdf_iterator.h:105
ogdf::AdjElement::theNode
node theNode() const
Returns the node whose adjacency list contains this element.
Definition: Graph_d.h:159
ogdf::internal::gcm::graph::EntryIterator
Definition: ogdf_iterator.h:72
ogdf::AdjElement::twin
adjEntry twin() const
Returns the corresponding adjacency element associated with the same edge.
Definition: Graph_d.h:165
ogdf::internal::gcm::graph::AdjacentNodeIterator
Definition: ogdf_iterator.h:97
ogdf::AdjElement
Class for adjacency list elements.
Definition: Graph_d.h:135
ogdf::internal::gcm::graph::OGDFEntryIterator< Entry >::Entry
Entry Entry
Definition: ogdf_iterator.h:45
ogdf::internal::gcm::graph::OGDFEntryIterator::operator++
Iterator & operator++()
Definition: ogdf_iterator.h:61
ogdf::edge
EdgeElement * edge
The type of edges.
Definition: Graph_d.h:67
ogdf::AdjElement::theEdge
edge theEdge() const
Returns the edge associated with this adjacency entry.
Definition: Graph_d.h:153
ogdf::internal::gcm::graph::OGDFEntryIterator
iterate over entries of an ogdf graph
Definition: ogdf_iterator.h:43
ogdf::internal::gcm::graph::OGDFEntryIterator::m_cur
Entry m_cur
Definition: ogdf_iterator.h:49
ogdf::internal::gcm::graph::OGDFEntryIterator::operator--
Iterator & operator--()
Definition: ogdf_iterator.h:56
ogdf::node
NodeElement * node
The type of nodes.
Definition: Graph_d.h:63
ogdf::internal::gcm::graph::IncidentEdgeIterator::operator*
edge operator*()
Definition: ogdf_iterator.h:92
ogdf::internal::gcm::graph::OGDFEntryIterator::operator==
bool operator==(const Iterator &b) const
Definition: ogdf_iterator.h:66
ogdf::internal::gcm::graph::EntryIterator::T
Entry T
Definition: ogdf_iterator.h:77
ogdf::internal::gcm::graph::OGDFEntryIterator::OGDFEntryIterator
OGDFEntryIterator(Entry _cur)
Definition: ogdf_iterator.h:52
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:356
ogdf::internal::gcm::graph::IncidentEdgeIterator
iterate over incident edges
Definition: ogdf_iterator.h:84
ogdf::internal::gcm::graph::EntryIterator::operator*
Entry operator*()
Definition: ogdf_iterator.h:80
ogdf::internal::gcm::graph::OGDFEntryIterator::operator!=
bool operator!=(const Iterator &b) const
Definition: ogdf_iterator.h:68
Graph_d.h
Pure declaration header, find template implementation in Graph.h.
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233