Tulip  5.3.0
Large graphs analysis and drawing
GraphIterators.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef TULIP_GRAPHITERATORS_H
22 #define TULIP_GRAPHITERATORS_H
23 #include <tulip/BasicIterators.h>
24 #include <tulip/tulipconf.h>
25 
26 namespace tlp {
27 
28 class Graph;
29 class GraphImpl;
30 class GraphView;
31 
32 //============================================================
33 /// Out node iterator for GraphView
34 class TLP_SCOPE OutNodesIterator : public FactorNodeIterator, public MemoryPool<OutNodesIterator> {
35 private:
36  Iterator<edge> *it;
37 #if !defined(NDEBUG) && !defined(_OPENMP)
38  const GraphView *sg;
39 #endif
40 public:
41  OutNodesIterator(const GraphView *sG, node n);
42  ~OutNodesIterator() override;
43  node next() override;
44  bool hasNext() override;
45 };
46 //============================================================
47 /// In node iterator for GraphView
48 class InNodesIterator : public FactorNodeIterator, public MemoryPool<InNodesIterator> {
49 private:
50  Iterator<edge> *it;
51 #if !defined(NDEBUG) && !defined(_OPENMP)
52  const GraphView *sg;
53 #endif
54 public:
55  InNodesIterator(const GraphView *sG, node n);
56  ~InNodesIterator() override;
57  node next() override;
58  bool hasNext() override;
59 };
60 //============================================================
61 /// In Out node iterator for GraphView
62 class TLP_SCOPE InOutNodesIterator : public FactorNodeIterator,
63  public MemoryPool<InOutNodesIterator> {
64 private:
65  Iterator<edge> *it;
66  node n;
67 #if !defined(NDEBUG) && !defined(_OPENMP)
68  const GraphView *sg;
69 #endif
70 public:
71  InOutNodesIterator(const GraphView *sG, node n);
72  ~InOutNodesIterator() override;
73  node next() override;
74  bool hasNext() override;
75 };
76 //============================================================
77 /// Out edge iterator for GraphView
78 class TLP_SCOPE OutEdgesIterator : public FactorEdgeIterator, public MemoryPool<OutEdgesIterator> {
79 private:
80  Iterator<edge> *it;
81  edge curEdge;
82  const GraphView *sg;
83 
84 public:
85  OutEdgesIterator(const GraphView *sG, node n);
86  ~OutEdgesIterator() override;
87  edge next() override;
88  bool hasNext() override;
89 
90 protected:
91  void prepareNext();
92 };
93 //============================================================
94 /// In edge iterator for GraphView
95 class TLP_SCOPE InEdgesIterator : public FactorEdgeIterator, public MemoryPool<InEdgesIterator> {
96 private:
97  Iterator<edge> *it;
98  edge curEdge;
99  const GraphView *sg;
100 
101 public:
102  InEdgesIterator(const GraphView *sG, node n);
103  ~InEdgesIterator() override;
104  edge next() override;
105  bool hasNext() override;
106 
107 protected:
108  void prepareNext();
109 };
110 //============================================================
111 /// In Out edge iterator for GraphView
112 class TLP_SCOPE InOutEdgesIterator : public FactorEdgeIterator,
113  public MemoryPool<InOutEdgesIterator> {
114 private:
115  Iterator<edge> *it;
116  edge curEdge;
117  const GraphView *sg;
118 
119 public:
120  InOutEdgesIterator(const GraphView *sG, node n);
121  ~InOutEdgesIterator() override;
122  edge next() override;
123  bool hasNext() override;
124 
125 protected:
126  void prepareNext();
127 };
128 
129 //============================================================
130 // Iterator for the Graph
131 //============================================================
132 class TLP_SCOPE GraphNodeIterator : public NodeIterator
133 #if defined(NDEBUG) || defined(_OPENMP)
134  ,
135  public MemoryPool<GraphNodeIterator>
136 #endif
137 {
138 private:
139 #if !defined(NDEBUG) && !defined(_OPENMP)
140  const Graph *graph;
141  void *ito;
142 #endif
143  Iterator<node> *itId;
144 
145 public:
146  GraphNodeIterator(const Graph *g, Iterator<node> *it);
147  ~GraphNodeIterator() override;
148  node next() override;
149  bool hasNext() override;
150 };
151 //=============================================================
152 /// Edge iterator for data sg
153 class TLP_SCOPE GraphEdgeIterator : public EdgeIterator
154 #if defined(NDEBUG) || defined(_OPENMP)
155  ,
156  public MemoryPool<GraphEdgeIterator>
157 #endif
158 {
159 private:
160 #if !defined(NDEBUG) && !defined(_OPENMP)
161  const Graph *graph;
162  void *ito;
163 #endif
164  Iterator<edge> *itId;
165 
166 public:
167  GraphEdgeIterator(const Graph *g, Iterator<edge> *it);
168  ~GraphEdgeIterator() override;
169  edge next() override;
170  bool hasNext() override;
171 };
172 //============================================================
173 } // namespace tlp
174 #endif
175 
176 ///@endcond