Removed references to the gui.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
19 #ifndef LEMON_CONCEPT_GRAPH_H
20 #define LEMON_CONCEPT_GRAPH_H
22 ///\ingroup graph_concepts
24 ///\brief Declaration of Graph.
26 #include <lemon/bits/invalid.h>
27 #include <lemon/bits/utility.h>
28 #include <lemon/concept/maps.h>
29 #include <lemon/concept_check.h>
30 #include <lemon/concept/graph_component.h>
35 /// \addtogroup graph_concepts
38 /// The directed graph concept
40 /// This class describes the \ref concept "concept" of the
41 /// immutable directed graphs.
43 /// Note that actual graph implementation like @ref ListGraph or
44 /// @ref SmartGraph may have several additional functionality.
51 /// Defalult constructor.
53 /// Defalult constructor.
57 /// The base type of node iterators,
58 /// or in other words, the trivial node iterator.
60 /// This is the base type of each node iterator,
61 /// thus each kind of node iterator converts to this.
62 /// More precisely each kind of node iterator should be inherited
63 /// from the trivial node iterator.
66 /// Default constructor
68 /// @warning The default constructor sets the iterator
69 /// to an undefined value.
77 /// Invalid constructor \& conversion.
79 /// This constructor initializes the iterator to be invalid.
80 /// \sa Invalid for more details.
84 /// Two iterators are equal if and only if they point to the
85 /// same object or both are invalid.
86 bool operator==(Node) const { return true; }
88 /// Inequality operator
90 /// \sa operator==(Node n)
92 bool operator!=(Node) const { return true; }
94 /// Artificial ordering operator.
96 /// To allow the use of graph descriptors as key type in std::map or
97 /// similar associative container we require this.
99 /// \note This operator only have to define some strict ordering of
100 /// the items; this order has nothing to do with the iteration
101 /// ordering of the items.
102 bool operator<(Node) const { return false; }
106 /// This iterator goes through each node.
108 /// This iterator goes through each node.
109 /// Its usage is quite simple, for example you can count the number
110 /// of nodes in graph \c g of type \c Graph like this:
113 /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
115 class NodeIt : public Node {
117 /// Default constructor
119 /// @warning The default constructor sets the iterator
120 /// to an undefined value.
122 /// Copy constructor.
124 /// Copy constructor.
126 NodeIt(const NodeIt& n) : Node(n) { }
127 /// Invalid constructor \& conversion.
129 /// Initialize the iterator to be invalid.
130 /// \sa Invalid for more details.
132 /// Sets the iterator to the first node.
134 /// Sets the iterator to the first node of \c g.
136 NodeIt(const Graph&) { }
137 /// Node -> NodeIt conversion.
139 /// Sets the iterator to the node of \c the graph pointed by
140 /// the trivial iterator.
141 /// This feature necessitates that each time we
142 /// iterate the edge-set, the iteration order is the same.
143 NodeIt(const Graph&, const Node&) { }
146 /// Assign the iterator to the next node.
148 NodeIt& operator++() { return *this; }
152 /// The base type of the edge iterators.
154 /// The base type of the edge iterators.
158 /// Default constructor
160 /// @warning The default constructor sets the iterator
161 /// to an undefined value.
163 /// Copy constructor.
165 /// Copy constructor.
167 Edge(const Edge&) { }
168 /// Initialize the iterator to be invalid.
170 /// Initialize the iterator to be invalid.
173 /// Equality operator
175 /// Two iterators are equal if and only if they point to the
176 /// same object or both are invalid.
177 bool operator==(Edge) const { return true; }
178 /// Inequality operator
180 /// \sa operator==(Edge n)
182 bool operator!=(Edge) const { return true; }
184 /// Artificial ordering operator.
186 /// To allow the use of graph descriptors as key type in std::map or
187 /// similar associative container we require this.
189 /// \note This operator only have to define some strict ordering of
190 /// the items; this order has nothing to do with the iteration
191 /// ordering of the items.
192 bool operator<(Edge) const { return false; }
195 /// This iterator goes trough the outgoing edges of a node.
197 /// This iterator goes trough the \e outgoing edges of a certain node
199 /// Its usage is quite simple, for example you can count the number
200 /// of outgoing edges of a node \c n
201 /// in graph \c g of type \c Graph as follows.
204 /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count;
207 class OutEdgeIt : public Edge {
209 /// Default constructor
211 /// @warning The default constructor sets the iterator
212 /// to an undefined value.
214 /// Copy constructor.
216 /// Copy constructor.
218 OutEdgeIt(const OutEdgeIt& e) : Edge(e) { }
219 /// Initialize the iterator to be invalid.
221 /// Initialize the iterator to be invalid.
223 OutEdgeIt(Invalid) { }
224 /// This constructor sets the iterator to the first outgoing edge.
226 /// This constructor sets the iterator to the first outgoing edge of
228 OutEdgeIt(const Graph&, const Node&) { }
229 /// Edge -> OutEdgeIt conversion
231 /// Sets the iterator to the value of the trivial iterator.
232 /// This feature necessitates that each time we
233 /// iterate the edge-set, the iteration order is the same.
234 OutEdgeIt(const Graph&, const Edge&) { }
235 ///Next outgoing edge
237 /// Assign the iterator to the next
238 /// outgoing edge of the corresponding node.
239 OutEdgeIt& operator++() { return *this; }
242 /// This iterator goes trough the incoming edges of a node.
244 /// This iterator goes trough the \e incoming edges of a certain node
246 /// Its usage is quite simple, for example you can count the number
247 /// of outgoing edges of a node \c n
248 /// in graph \c g of type \c Graph as follows.
251 /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count;
254 class InEdgeIt : public Edge {
256 /// Default constructor
258 /// @warning The default constructor sets the iterator
259 /// to an undefined value.
261 /// Copy constructor.
263 /// Copy constructor.
265 InEdgeIt(const InEdgeIt& e) : Edge(e) { }
266 /// Initialize the iterator to be invalid.
268 /// Initialize the iterator to be invalid.
270 InEdgeIt(Invalid) { }
271 /// This constructor sets the iterator to first incoming edge.
273 /// This constructor set the iterator to the first incoming edge of
275 InEdgeIt(const Graph&, const Node&) { }
276 /// Edge -> InEdgeIt conversion
278 /// Sets the iterator to the value of the trivial iterator \c e.
279 /// This feature necessitates that each time we
280 /// iterate the edge-set, the iteration order is the same.
281 InEdgeIt(const Graph&, const Edge&) { }
282 /// Next incoming edge
284 /// Assign the iterator to the next inedge of the corresponding node.
286 InEdgeIt& operator++() { return *this; }
288 /// This iterator goes through each edge.
290 /// This iterator goes through each edge of a graph.
291 /// Its usage is quite simple, for example you can count the number
292 /// of edges in a graph \c g of type \c Graph as follows:
295 /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
297 class EdgeIt : public Edge {
299 /// Default constructor
301 /// @warning The default constructor sets the iterator
302 /// to an undefined value.
304 /// Copy constructor.
306 /// Copy constructor.
308 EdgeIt(const EdgeIt& e) : Edge(e) { }
309 /// Initialize the iterator to be invalid.
311 /// Initialize the iterator to be invalid.
314 /// This constructor sets the iterator to the first edge.
316 /// This constructor sets the iterator to the first edge of \c g.
317 ///@param g the graph
318 EdgeIt(const Graph& g) { ignore_unused_variable_warning(g); }
319 /// Edge -> EdgeIt conversion
321 /// Sets the iterator to the value of the trivial iterator \c e.
322 /// This feature necessitates that each time we
323 /// iterate the edge-set, the iteration order is the same.
324 EdgeIt(const Graph&, const Edge&) { }
327 /// Assign the iterator to the next edge.
328 EdgeIt& operator++() { return *this; }
330 ///Gives back the target node of an edge.
332 ///Gives back the target node of an edge.
334 Node target(Edge) const { return INVALID; }
335 ///Gives back the source node of an edge.
337 ///Gives back the source node of an edge.
339 Node source(Edge) const { return INVALID; }
341 void first(Node&) const {}
342 void next(Node&) const {}
344 void first(Edge&) const {}
345 void next(Edge&) const {}
348 void firstIn(Edge&, const Node&) const {}
349 void nextIn(Edge&) const {}
351 void firstOut(Edge&, const Node&) const {}
352 void nextOut(Edge&) const {}
354 /// \brief The base node of the iterator.
356 /// Gives back the base node of the iterator.
357 /// It is always the target of the pointed edge.
358 Node baseNode(const InEdgeIt&) const { return INVALID; }
360 /// \brief The running node of the iterator.
362 /// Gives back the running node of the iterator.
363 /// It is always the source of the pointed edge.
364 Node runningNode(const InEdgeIt&) const { return INVALID; }
366 /// \brief The base node of the iterator.
368 /// Gives back the base node of the iterator.
369 /// It is always the source of the pointed edge.
370 Node baseNode(const OutEdgeIt&) const { return INVALID; }
372 /// \brief The running node of the iterator.
374 /// Gives back the running node of the iterator.
375 /// It is always the target of the pointed edge.
376 Node runningNode(const OutEdgeIt&) const { return INVALID; }
378 /// \brief The opposite node on the given edge.
380 /// Gives back the opposite node on the given edge.
381 Node oppositeNode(const Node&, const Edge&) const { return INVALID; }
383 /// \brief Read write map of the nodes to type \c T.
385 /// ReadWrite map of the nodes to type \c T.
387 /// \warning Making maps that can handle bool type (NodeMap<bool>)
388 /// needs some extra attention!
390 class NodeMap : public ReadWriteMap< Node, T > {
394 NodeMap(const Graph&) { }
396 NodeMap(const Graph&, T) { }
399 NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
400 ///Assignment operator
401 template <typename CMap>
402 NodeMap& operator=(const CMap&) {
403 checkConcept<ReadMap<Node, T>, CMap>();
408 /// \brief Read write map of the edges to type \c T.
410 /// Reference map of the edges to type \c T.
412 /// \warning Making maps that can handle bool type (EdgeMap<bool>)
413 /// needs some extra attention!
415 class EdgeMap : public ReadWriteMap<Edge,T> {
419 EdgeMap(const Graph&) { }
421 EdgeMap(const Graph&, T) { }
423 EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { }
424 ///Assignment operator
425 template <typename CMap>
426 EdgeMap& operator=(const CMap&) {
427 checkConcept<ReadMap<Edge, T>, CMap>();
432 template <typename RGraph>
435 checkConcept<BaseIterableGraphComponent<>, Graph>();
436 checkConcept<IterableGraphComponent<>, Graph>();
437 checkConcept<MappableGraphComponent<>, Graph>();
444 } //namespace concept
449 #endif // LEMON_CONCEPT_GRAPH_H