25 |
25 |
26 #include <lemon/core.h> |
26 #include <lemon/core.h> |
27 #include <lemon/concepts/maps.h> |
27 #include <lemon/concepts/maps.h> |
28 #include <lemon/concept_check.h> |
28 #include <lemon/concept_check.h> |
29 #include <lemon/concepts/graph_components.h> |
29 #include <lemon/concepts/graph_components.h> |
|
30 #include <lemon/bits/stl_iterators.h> |
30 |
31 |
31 namespace lemon { |
32 namespace lemon { |
32 namespace concepts { |
33 namespace concepts { |
33 |
34 |
34 /// \ingroup graph_concepts |
35 /// \ingroup graph_concepts |
145 /// Assign the iterator to the next node. |
146 /// Assign the iterator to the next node. |
146 /// |
147 /// |
147 NodeIt& operator++() { return *this; } |
148 NodeIt& operator++() { return *this; } |
148 }; |
149 }; |
149 |
150 |
|
151 /// \brief Gets the collection of the nodes of the digraph. |
|
152 /// |
|
153 /// This function can be used for iterating on |
|
154 /// the nodes of the digraph. It returns a wrapped NodeIt, which looks |
|
155 /// like an STL container (by having begin() and end()) |
|
156 /// which you can use in range-based for loops, STL algorithms, etc. |
|
157 /// For example you can write: |
|
158 ///\code |
|
159 /// ListDigraph g; |
|
160 /// for(auto v: g.nodes()) |
|
161 /// doSomething(v); |
|
162 /// |
|
163 /// //Using an STL algorithm: |
|
164 /// copy(g.nodes().begin(), g.nodes().end(), vect.begin()); |
|
165 ///\endcode |
|
166 LemonRangeWrapper1<NodeIt, Digraph> nodes() const { |
|
167 return LemonRangeWrapper1<NodeIt, Digraph>(*this); |
|
168 } |
|
169 |
150 |
170 |
151 /// The arc type of the digraph |
171 /// The arc type of the digraph |
152 |
172 |
153 /// This class identifies an arc of the digraph. It also serves |
173 /// This class identifies an arc of the digraph. It also serves |
154 /// as a base class of the arc iterators, |
174 /// as a base class of the arc iterators, |
235 /// Assign the iterator to the next |
255 /// Assign the iterator to the next |
236 /// outgoing arc of the corresponding node. |
256 /// outgoing arc of the corresponding node. |
237 OutArcIt& operator++() { return *this; } |
257 OutArcIt& operator++() { return *this; } |
238 }; |
258 }; |
239 |
259 |
|
260 /// \brief Gets the collection of the outgoing arcs of a certain node |
|
261 /// of the digraph. |
|
262 /// |
|
263 /// This function can be used for iterating on the |
|
264 /// outgoing arcs of a certain node of the digraph. It returns a wrapped |
|
265 /// OutArcIt, which looks like an STL container |
|
266 /// (by having begin() and end()) which you can use in range-based |
|
267 /// for loops, STL algorithms, etc. |
|
268 /// For example if g is a Digraph and u is a node, you can write: |
|
269 ///\code |
|
270 /// for(auto a: g.outArcs(u)) |
|
271 /// doSomething(a); |
|
272 /// |
|
273 /// //Using an STL algorithm: |
|
274 /// copy(g.outArcs(u).begin(), g.outArcs(u).end(), vect.begin()); |
|
275 ///\endcode |
|
276 LemonRangeWrapper2<OutArcIt, Digraph, Node> outArcs(const Node& u) const { |
|
277 return LemonRangeWrapper2<OutArcIt, Digraph, Node>(*this, u); |
|
278 } |
|
279 |
|
280 |
240 /// Iterator class for the incoming arcs of a node. |
281 /// Iterator class for the incoming arcs of a node. |
241 |
282 |
242 /// This iterator goes trough the \e incoming arcs of a certain node |
283 /// This iterator goes trough the \e incoming arcs of a certain node |
243 /// of a digraph. |
284 /// of a digraph. |
244 /// Its usage is quite simple, for example, you can count the number |
285 /// Its usage is quite simple, for example, you can count the number |
280 /// Assign the iterator to the next |
321 /// Assign the iterator to the next |
281 /// incoming arc of the corresponding node. |
322 /// incoming arc of the corresponding node. |
282 InArcIt& operator++() { return *this; } |
323 InArcIt& operator++() { return *this; } |
283 }; |
324 }; |
284 |
325 |
|
326 /// \brief Gets the collection of the incoming arcs of a certain node |
|
327 /// of the digraph. |
|
328 /// |
|
329 /// This function can be used for iterating on the |
|
330 /// incoming arcs of a certain node of the digraph. It returns a wrapped |
|
331 /// InArcIt, which looks like an STL container |
|
332 /// (by having begin() and end()) which you can use in range-based |
|
333 /// for loops, STL algorithms, etc. |
|
334 /// For example if g is a Digraph and u is a node, you can write: |
|
335 ///\code |
|
336 /// for(auto a: g.inArcs(u)) |
|
337 /// doSomething(a); |
|
338 /// |
|
339 /// //Using an STL algorithm: |
|
340 /// copy(g.inArcs(u).begin(), g.inArcs(u).end(), vect.begin()); |
|
341 ///\endcode |
|
342 LemonRangeWrapper2<InArcIt, Digraph, Node> inArcs(const Node& u) const { |
|
343 return LemonRangeWrapper2<InArcIt, Digraph, Node>(*this, u); |
|
344 } |
|
345 |
|
346 |
285 /// Iterator class for the arcs. |
347 /// Iterator class for the arcs. |
286 |
348 |
287 /// This iterator goes through each arc of the digraph. |
349 /// This iterator goes through each arc of the digraph. |
288 /// Its usage is quite simple, for example, you can count the number |
350 /// Its usage is quite simple, for example, you can count the number |
289 /// of arcs in a digraph \c g of type \c %Digraph as follows: |
351 /// of arcs in a digraph \c g of type \c %Digraph as follows: |
324 |
386 |
325 /// Assign the iterator to the next arc. |
387 /// Assign the iterator to the next arc. |
326 /// |
388 /// |
327 ArcIt& operator++() { return *this; } |
389 ArcIt& operator++() { return *this; } |
328 }; |
390 }; |
|
391 |
|
392 /// \brief Gets the collection of the arcs of the digraph. |
|
393 /// |
|
394 /// This function can be used for iterating on the |
|
395 /// arcs of the digraph. It returns a wrapped |
|
396 /// ArcIt, which looks like an STL container |
|
397 /// (by having begin() and end()) which you can use in range-based |
|
398 /// for loops, STL algorithms, etc. |
|
399 /// For example you can write: |
|
400 ///\code |
|
401 /// ListDigraph g; |
|
402 /// for(auto a: g.arcs()) |
|
403 /// doSomething(a); |
|
404 /// |
|
405 /// //Using an STL algorithm: |
|
406 /// copy(g.arcs().begin(), g.arcs().end(), vect.begin()); |
|
407 ///\endcode |
|
408 LemonRangeWrapper1<ArcIt, Digraph> arcs() const { |
|
409 return LemonRangeWrapper1<ArcIt, Digraph>(*this); |
|
410 } |
|
411 |
329 |
412 |
330 /// \brief The source node of the arc. |
413 /// \brief The source node of the arc. |
331 /// |
414 /// |
332 /// Returns the source node of the given arc. |
415 /// Returns the source node of the given arc. |
333 Node source(Arc) const { return INVALID; } |
416 Node source(Arc) const { return INVALID; } |