lemon/concept/undir_graph.h
changeset 1628 191264dc6925
parent 1624 61cc647dac99
child 1630 f67737f5727a
equal deleted inserted replaced
3:fbefe380d77f 4:6b8f2ffd4d6b
   117 	  n = graph.target(ue);
   117 	  n = graph.target(ue);
   118 	  n = graph.source(ue);
   118 	  n = graph.source(ue);
   119 	  n = graph.oppositeNode(n0, ue);
   119 	  n = graph.oppositeNode(n0, ue);
   120 
   120 
   121 	  bool b;
   121 	  bool b;
   122 	  b = graph.forward(e);
   122 	  b = graph.direction(e);
       
   123 	  Edge e = graph.direct(UndirEdge(), true);
       
   124 	  e = graph.direct(UndirEdge(), n);
       
   125  
   123 	  ignore_unused_variable_warning(b);
   126 	  ignore_unused_variable_warning(b);
   124 	}
   127 	}
   125 
   128 
   126 	Graph graph;
   129 	Graph graph;
   127 	Edge e;
   130 	Edge e;
   230     ///
   233     ///
   231     /// In LEMON undirected graphs also fulfill the concept of directed
   234     /// In LEMON undirected graphs also fulfill the concept of directed
   232     /// graphs (\ref lemon::concept::Graph "Graph Concept"). For
   235     /// graphs (\ref lemon::concept::Graph "Graph Concept"). For
   233     /// explanation of this and more see also the page \ref undir_graphs,
   236     /// explanation of this and more see also the page \ref undir_graphs,
   234     /// a tutorial about undirected graphs.
   237     /// a tutorial about undirected graphs.
   235 
   238     ///
   236     class UndirGraph : public StaticGraph {
   239     /// You can assume that all undirected graph can be handled
       
   240     /// as a static directed graph. This way it is fully conform
       
   241     /// to the StaticGraph concept.
       
   242 
       
   243     class UndirGraph {
   237     public:
   244     public:
   238       ///\e
   245       ///\e
   239 
   246 
   240       ///\todo undocumented
   247       ///\todo undocumented
   241       ///
   248       ///
   242       typedef True UndirTag;
   249       typedef True UndirTag;
   243 
   250 
       
   251       /// The base type of node iterators, 
       
   252       /// or in other words, the trivial node iterator.
       
   253 
       
   254       /// This is the base type of each node iterator,
       
   255       /// thus each kind of node iterator converts to this.
       
   256       /// More precisely each kind of node iterator should be inherited 
       
   257       /// from the trivial node iterator.
       
   258       class Node {
       
   259       public:
       
   260         /// Default constructor
       
   261 
       
   262         /// @warning The default constructor sets the iterator
       
   263         /// to an undefined value.
       
   264         Node() { }
       
   265         /// Copy constructor.
       
   266 
       
   267         /// Copy constructor.
       
   268         ///
       
   269         Node(const Node&) { }
       
   270 
       
   271         /// Invalid constructor \& conversion.
       
   272 
       
   273         /// This constructor initializes the iterator to be invalid.
       
   274         /// \sa Invalid for more details.
       
   275         Node(Invalid) { }
       
   276         /// Equality operator
       
   277 
       
   278         /// Two iterators are equal if and only if they point to the
       
   279         /// same object or both are invalid.
       
   280         bool operator==(Node) const { return true; }
       
   281 
       
   282         /// Inequality operator
       
   283         
       
   284         /// \sa operator==(Node n)
       
   285         ///
       
   286         bool operator!=(Node) const { return true; }
       
   287 
       
   288 	/// Artificial ordering operator.
       
   289 	
       
   290 	/// To allow the use of graph descriptors as key type in std::map or
       
   291 	/// similar associative container we require this.
       
   292 	///
       
   293 	/// \note This operator only have to define some strict ordering of
       
   294 	/// the items; this order has nothing to do with the iteration
       
   295 	/// ordering of the items.
       
   296 	///
       
   297 	/// \bug This is a technical requirement. Do we really need this?
       
   298 	bool operator<(Node) const { return false; }
       
   299 
       
   300       };
       
   301     
       
   302       /// This iterator goes through each node.
       
   303 
       
   304       /// This iterator goes through each node.
       
   305       /// Its usage is quite simple, for example you can count the number
       
   306       /// of nodes in graph \c g of type \c Graph like this:
       
   307       /// \code
       
   308       /// int count=0;
       
   309       /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
       
   310       /// \endcode
       
   311       class NodeIt : public Node {
       
   312       public:
       
   313         /// Default constructor
       
   314 
       
   315         /// @warning The default constructor sets the iterator
       
   316         /// to an undefined value.
       
   317         NodeIt() { }
       
   318         /// Copy constructor.
       
   319         
       
   320         /// Copy constructor.
       
   321         ///
       
   322         NodeIt(const NodeIt& n) : Node(n) { }
       
   323         /// Invalid constructor \& conversion.
       
   324 
       
   325         /// Initialize the iterator to be invalid.
       
   326         /// \sa Invalid for more details.
       
   327         NodeIt(Invalid) { }
       
   328         /// Sets the iterator to the first node.
       
   329 
       
   330         /// Sets the iterator to the first node of \c g.
       
   331         ///
       
   332         NodeIt(const UndirGraph&) { }
       
   333         /// Node -> NodeIt conversion.
       
   334 
       
   335         /// Sets the iterator to the node of \c the graph pointed by 
       
   336 	/// the trivial iterator.
       
   337         /// This feature necessitates that each time we 
       
   338         /// iterate the edge-set, the iteration order is the same.
       
   339         NodeIt(const UndirGraph&, const Node&) { }
       
   340         /// Next node.
       
   341 
       
   342         /// Assign the iterator to the next node.
       
   343         ///
       
   344         NodeIt& operator++() { return *this; }
       
   345       };
       
   346     
       
   347     
   244       /// The base type of the undirected edge iterators.
   348       /// The base type of the undirected edge iterators.
   245       
   349 
   246       /// The base type of the undirected edge iterators.
   350       /// The base type of the undirected edge iterators.
   247       ///
   351       ///
   248       class UndirEdge {
   352       class UndirEdge {
   249       public:
   353       public:
   250         /// Default constructor
   354         /// Default constructor
   255         /// Copy constructor.
   359         /// Copy constructor.
   256 
   360 
   257         /// Copy constructor.
   361         /// Copy constructor.
   258         ///
   362         ///
   259         UndirEdge(const UndirEdge&) { }
   363         UndirEdge(const UndirEdge&) { }
   260         /// Edge -> UndirEdge conversion
       
   261 
       
   262         /// Edge -> UndirEdge conversion
       
   263         ///
       
   264         UndirEdge(const Edge&) { }
       
   265         /// Initialize the iterator to be invalid.
   364         /// Initialize the iterator to be invalid.
   266 
   365 
   267         /// Initialize the iterator to be invalid.
   366         /// Initialize the iterator to be invalid.
   268         ///
   367         ///
   269         UndirEdge(Invalid) { }
   368         UndirEdge(Invalid) { }
   276 
   375 
   277         /// \sa operator==(UndirEdge n)
   376         /// \sa operator==(UndirEdge n)
   278         ///
   377         ///
   279         bool operator!=(UndirEdge) const { return true; }
   378         bool operator!=(UndirEdge) const { return true; }
   280 
   379 
   281 	///\e
   380 	/// Artificial ordering operator.
   282 
   381 	
   283 	///\todo Do we need this?
   382 	/// To allow the use of graph descriptors as key type in std::map or
       
   383 	/// similar associative container we require this.
   284 	///
   384 	///
   285 	bool operator<(const UndirEdge &that) const { return true; }
   385 	/// \note This operator only have to define some strict ordering of
   286       };
   386 	/// the items; this order has nothing to do with the iteration
   287     
   387 	/// ordering of the items.
       
   388 	///
       
   389 	/// \bug This is a technical requirement. Do we really need this?
       
   390 	bool operator<(UndirEdge) const { return false; }
       
   391       };
       
   392 
   288       /// This iterator goes through each undirected edge.
   393       /// This iterator goes through each undirected edge.
   289 
   394 
   290       /// This iterator goes through each undirected edge of a graph.
   395       /// This iterator goes through each undirected edge of a graph.
   291       /// Its usage is quite simple, for example you can count the number
   396       /// 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:
   397       /// of undirected edges in a graph \c g of type \c Graph as follows:
   293       /// \code
   398       /// \code
   294       /// int count=0;
   399       /// int count=0;
   295       /// for(Graph::UndirEdgeIt e(g); e!=INVALID; ++e) ++count;
   400       /// for(Graph::UndirEdgeIt e(g); e!=INVALID; ++e) ++count;
   296       /// \endcode
   401       /// \endcode
   297       class UndirEdgeIt : public UndirEdge {
   402       class UndirEdgeIt : public UndirEdge {
   298       public:
   403       public:
   299         /// Default constructor
   404         /// Default constructor
   300 	
   405 
   301         /// @warning The default constructor sets the iterator
   406         /// @warning The default constructor sets the iterator
   302         /// to an undefined value.
   407         /// to an undefined value.
   303         UndirEdgeIt() { }
   408         UndirEdgeIt() { }
   304         /// Copy constructor.
   409         /// Copy constructor.
   305 	
   410 
   306         /// Copy constructor.
   411         /// Copy constructor.
   307         ///
   412         ///
   308         UndirEdgeIt(const UndirEdgeIt& e) : UndirEdge(e) { }
   413         UndirEdgeIt(const UndirEdgeIt& e) : UndirEdge(e) { }
   309         /// Initialize the iterator to be invalid.
   414         /// Initialize the iterator to be invalid.
   310 
   415 
   311         /// Initialize the iterator to be invalid.
   416         /// Initialize the iterator to be invalid.
   312         ///
   417         ///
   313         UndirEdgeIt(Invalid) { }
   418         UndirEdgeIt(Invalid) { }
   314         /// This constructor sets the iterator to the first edge.
   419         /// This constructor sets the iterator to the first undirected edge.
   315     
   420     
   316         /// This constructor sets the iterator to the first edge of \c g.
   421         /// This constructor sets the iterator to the first undirected edge.
   317         UndirEdgeIt(const UndirGraph&) { }
   422         UndirEdgeIt(const UndirGraph&) { }
   318         /// UndirEdge -> UndirEdgeIt conversion
   423         /// UndirEdge -> UndirEdgeIt conversion
   319 
   424 
   320         /// Sets the iterator to the value of the trivial iterator \c e.
   425         /// Sets the iterator to the value of the trivial iterator.
   321         /// This feature necessitates that each time we 
   426         /// This feature necessitates that each time we
   322         /// iterate the edge-set, the iteration order is the same.
   427         /// iterate the undirected edge-set, the iteration order is the 
       
   428 	/// same.
   323         UndirEdgeIt(const UndirGraph&, const UndirEdge&) { } 
   429         UndirEdgeIt(const UndirGraph&, const UndirEdge&) { } 
   324         ///Next edge
   430         /// Next undirected edge
   325         
   431         
   326         /// Assign the iterator to the next edge.
   432         /// Assign the iterator to the next undirected edge.
   327         UndirEdgeIt& operator++() { return *this; }
   433         UndirEdgeIt& operator++() { return *this; }
   328       };
   434       };
   329 
   435 
   330       /// This iterator goes trough the incident undirected edges of a node.
   436       /// \brief This iterator goes trough the incident undirected 
   331 
   437       /// edges of a node.
       
   438       ///
   332       /// This iterator goes trough the incident undirected edges
   439       /// This iterator goes trough the incident undirected edges
   333       /// of a certain node
   440       /// of a certain node
   334       /// of a graph.
   441       /// of a graph.
   335       /// Its usage is quite simple, for example you can compute the
   442       /// Its usage is quite simple, for example you can compute the
   336       /// degree (i.e. count the number
   443       /// degree (i.e. count the number
   373         /// Assign the iterator to the next incident edge
   480         /// Assign the iterator to the next incident edge
   374 	/// of the corresponding node.
   481 	/// of the corresponding node.
   375         IncEdgeIt& operator++() { return *this; }
   482         IncEdgeIt& operator++() { return *this; }
   376       };
   483       };
   377 
   484 
       
   485       /// The directed edge type.
       
   486 
       
   487       /// The directed edge type. It can be converted to the
       
   488       /// undirected edge.
       
   489       class Edge : public UndirEdge {
       
   490       public:
       
   491         /// Default constructor
       
   492 
       
   493         /// @warning The default constructor sets the iterator
       
   494         /// to an undefined value.
       
   495         Edge() { }
       
   496         /// Copy constructor.
       
   497 
       
   498         /// Copy constructor.
       
   499         ///
       
   500         Edge(const Edge& e) : UndirEdge(e) { }
       
   501         /// Initialize the iterator to be invalid.
       
   502 
       
   503         /// Initialize the iterator to be invalid.
       
   504         ///
       
   505         Edge(Invalid) { }
       
   506         /// Equality operator
       
   507 
       
   508         /// Two iterators are equal if and only if they point to the
       
   509         /// same object or both are invalid.
       
   510         bool operator==(Edge) const { return true; }
       
   511         /// Inequality operator
       
   512 
       
   513         /// \sa operator==(Edge n)
       
   514         ///
       
   515         bool operator!=(Edge) const { return true; }
       
   516 
       
   517 	/// Artificial ordering operator.
       
   518 	
       
   519 	/// To allow the use of graph descriptors as key type in std::map or
       
   520 	/// similar associative container we require this.
       
   521 	///
       
   522 	/// \note This operator only have to define some strict ordering of
       
   523 	/// the items; this order has nothing to do with the iteration
       
   524 	/// ordering of the items.
       
   525 	///
       
   526 	/// \bug This is a technical requirement. Do we really need this?
       
   527 	bool operator<(Edge) const { return false; }
       
   528 	
       
   529       }; 
       
   530       /// This iterator goes through each directed edge.
       
   531 
       
   532       /// This iterator goes through each edge of a graph.
       
   533       /// Its usage is quite simple, for example you can count the number
       
   534       /// of edges in a graph \c g of type \c Graph as follows:
       
   535       /// \code
       
   536       /// int count=0;
       
   537       /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
       
   538       /// \endcode
       
   539       class EdgeIt : public Edge {
       
   540       public:
       
   541         /// Default constructor
       
   542 
       
   543         /// @warning The default constructor sets the iterator
       
   544         /// to an undefined value.
       
   545         EdgeIt() { }
       
   546         /// Copy constructor.
       
   547 
       
   548         /// Copy constructor.
       
   549         ///
       
   550         EdgeIt(const EdgeIt& e) : Edge(e) { }
       
   551         /// Initialize the iterator to be invalid.
       
   552 
       
   553         /// Initialize the iterator to be invalid.
       
   554         ///
       
   555         EdgeIt(Invalid) { }
       
   556         /// This constructor sets the iterator to the first edge.
       
   557     
       
   558         /// This constructor sets the iterator to the first edge of \c g.
       
   559         ///@param g the graph
       
   560         EdgeIt(const UndirGraph&) { }
       
   561         /// Edge -> EdgeIt conversion
       
   562 
       
   563         /// Sets the iterator to the value of the trivial iterator \c e.
       
   564         /// This feature necessitates that each time we 
       
   565         /// iterate the edge-set, the iteration order is the same.
       
   566         EdgeIt(const UndirGraph&, const Edge&) { } 
       
   567         ///Next edge
       
   568         
       
   569         /// Assign the iterator to the next edge.
       
   570         EdgeIt& operator++() { return *this; }
       
   571       };
       
   572    
       
   573       /// This iterator goes trough the outgoing directed edges of a node.
       
   574 
       
   575       /// This iterator goes trough the \e outgoing edges of a certain node
       
   576       /// of a graph.
       
   577       /// Its usage is quite simple, for example you can count the number
       
   578       /// of outgoing edges of a node \c n
       
   579       /// in graph \c g of type \c Graph as follows.
       
   580       /// \code
       
   581       /// int count=0;
       
   582       /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count;
       
   583       /// \endcode
       
   584     
       
   585       class OutEdgeIt : public Edge {
       
   586       public:
       
   587         /// Default constructor
       
   588 
       
   589         /// @warning The default constructor sets the iterator
       
   590         /// to an undefined value.
       
   591         OutEdgeIt() { }
       
   592         /// Copy constructor.
       
   593 
       
   594         /// Copy constructor.
       
   595         ///
       
   596         OutEdgeIt(const OutEdgeIt& e) : Edge(e) { }
       
   597         /// Initialize the iterator to be invalid.
       
   598 
       
   599         /// Initialize the iterator to be invalid.
       
   600         ///
       
   601         OutEdgeIt(Invalid) { }
       
   602         /// This constructor sets the iterator to the first outgoing edge.
       
   603     
       
   604         /// This constructor sets the iterator to the first outgoing edge of
       
   605         /// the node.
       
   606         ///@param n the node
       
   607         ///@param g the graph
       
   608         OutEdgeIt(const UndirGraph&, const Node&) { }
       
   609         /// Edge -> OutEdgeIt conversion
       
   610 
       
   611         /// Sets the iterator to the value of the trivial iterator.
       
   612 	/// This feature necessitates that each time we 
       
   613         /// iterate the edge-set, the iteration order is the same.
       
   614         OutEdgeIt(const UndirGraph&, const Edge&) { }
       
   615         ///Next outgoing edge
       
   616         
       
   617         /// Assign the iterator to the next 
       
   618         /// outgoing edge of the corresponding node.
       
   619         OutEdgeIt& operator++() { return *this; }
       
   620       };
       
   621 
       
   622       /// This iterator goes trough the incoming directed edges of a node.
       
   623 
       
   624       /// This iterator goes trough the \e incoming edges of a certain node
       
   625       /// of a graph.
       
   626       /// Its usage is quite simple, for example you can count the number
       
   627       /// of outgoing edges of a node \c n
       
   628       /// in graph \c g of type \c Graph as follows.
       
   629       /// \code
       
   630       /// int count=0;
       
   631       /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count;
       
   632       /// \endcode
       
   633 
       
   634       class InEdgeIt : public Edge {
       
   635       public:
       
   636         /// Default constructor
       
   637 
       
   638         /// @warning The default constructor sets the iterator
       
   639         /// to an undefined value.
       
   640         InEdgeIt() { }
       
   641         /// Copy constructor.
       
   642 
       
   643         /// Copy constructor.
       
   644         ///
       
   645         InEdgeIt(const InEdgeIt& e) : Edge(e) { }
       
   646         /// Initialize the iterator to be invalid.
       
   647 
       
   648         /// Initialize the iterator to be invalid.
       
   649         ///
       
   650         InEdgeIt(Invalid) { }
       
   651         /// This constructor sets the iterator to first incoming edge.
       
   652     
       
   653         /// This constructor set the iterator to the first incoming edge of
       
   654         /// the node.
       
   655         ///@param n the node
       
   656         ///@param g the graph
       
   657         InEdgeIt(const UndirGraph&, const Node&) { }
       
   658         /// Edge -> InEdgeIt conversion
       
   659 
       
   660         /// Sets the iterator to the value of the trivial iterator \c e.
       
   661         /// This feature necessitates that each time we 
       
   662         /// iterate the edge-set, the iteration order is the same.
       
   663         InEdgeIt(const UndirGraph&, const Edge&) { }
       
   664         /// Next incoming edge
       
   665 
       
   666         /// Assign the iterator to the next inedge of the corresponding node.
       
   667         ///
       
   668         InEdgeIt& operator++() { return *this; }
       
   669       };
       
   670 
       
   671       /// \brief Read write map of the nodes to type \c T.
       
   672       /// 
       
   673       /// ReadWrite map of the nodes to type \c T.
       
   674       /// \sa Reference
       
   675       /// \warning Making maps that can handle bool type (NodeMap<bool>)
       
   676       /// needs some extra attention!
       
   677       template<class T> 
       
   678       class NodeMap : public ReadWriteMap< Node, T >
       
   679       {
       
   680       public:
       
   681 
       
   682         ///\e
       
   683         NodeMap(const UndirGraph&) { }
       
   684         ///\e
       
   685         NodeMap(const UndirGraph&, T) { }
       
   686 
       
   687         ///Copy constructor
       
   688         NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
       
   689         ///Assignment operator
       
   690         NodeMap& operator=(const NodeMap&) { return *this; }
       
   691         // \todo fix this concept
       
   692       };
       
   693 
       
   694       /// \brief Read write map of the directed edges to type \c T.
       
   695       ///
       
   696       /// Reference map of the directed edges to type \c T.
       
   697       /// \sa Reference
       
   698       /// \warning Making maps that can handle bool type (EdgeMap<bool>)
       
   699       /// needs some extra attention!
       
   700       template<class T> 
       
   701       class EdgeMap : public ReadWriteMap<Edge,T>
       
   702       {
       
   703       public:
       
   704 
       
   705         ///\e
       
   706         EdgeMap(const UndirGraph&) { }
       
   707         ///\e
       
   708         EdgeMap(const UndirGraph&, T) { }
       
   709         ///Copy constructor
       
   710         EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { }
       
   711         ///Assignment operator
       
   712         EdgeMap& operator=(const EdgeMap&) { return *this; }
       
   713         // \todo fix this concept    
       
   714       };
       
   715 
   378       /// Read write map of the undirected edges to type \c T.
   716       /// Read write map of the undirected edges to type \c T.
   379 
   717 
   380       /// Reference map of the edges to type \c T.
   718       /// Reference map of the edges to type \c T.
   381       /// \sa Reference
   719       /// \sa Reference
   382       /// \warning Making maps that can handle bool type (UndirEdgeMap<bool>)
   720       /// \warning Making maps that can handle bool type (UndirEdgeMap<bool>)
   389         ///\e
   727         ///\e
   390         UndirEdgeMap(const UndirGraph&) { }
   728         UndirEdgeMap(const UndirGraph&) { }
   391         ///\e
   729         ///\e
   392         UndirEdgeMap(const UndirGraph&, T) { }
   730         UndirEdgeMap(const UndirGraph&, T) { }
   393         ///Copy constructor
   731         ///Copy constructor
   394         UndirEdgeMap(const UndirEdgeMap& em) : ReadWriteMap<UndirEdge,T>(em) { }
   732         UndirEdgeMap(const UndirEdgeMap& em) : ReadWriteMap<UndirEdge,T>(em) {}
   395         ///Assignment operator
   733         ///Assignment operator
   396         UndirEdgeMap &operator=(const UndirEdgeMap&) { return *this; }
   734         UndirEdgeMap &operator=(const UndirEdgeMap&) { return *this; }
   397         // \todo fix this concept    
   735         // \todo fix this concept    
   398       };
   736       };
   399 
   737 
   400       /// Is the Edge oriented "forward"?
   738       /// \brief Direct the given undirected edge.
   401 
   739       ///
       
   740       /// Direct the given undirected edge. The returned edge source
       
   741       /// will be the given edge.
       
   742       Edge direct(const UndirEdge&, const Node&) const {
       
   743 	return INVALID;
       
   744       }
       
   745 
       
   746       /// \brief Direct the given undirected edge.
       
   747       ///
       
   748       /// Direct the given undirected edge. The returned edge source
       
   749       /// will be the source of the undirected edge if the given bool
       
   750       /// is true.
       
   751       Edge direct(const UndirEdge&, bool) const {
       
   752 	return INVALID;
       
   753       }
       
   754 
       
   755       /// \brief Returns true if the edge has default orientation.
       
   756       ///
   402       /// Returns whether the given directed edge is same orientation as
   757       /// Returns whether the given directed edge is same orientation as
   403       /// the corresponding undirected edge.
   758       /// the corresponding undirected edge.
   404       ///
   759       bool direction(Edge) const { return true; }
   405       /// \todo "What does the direction of an undirected edge mean?"
   760 
   406       bool forward(Edge) const { return true; }
   761       /// \brief Returns the opposite directed edge.
   407 
   762       ///
   408       /// Opposite node on an edge
   763       /// Returns the opposite directed edge.
   409 
   764       Edge oppositeEdge(Edge) const { return INVALID; }
       
   765 
       
   766       /// \brief Opposite node on an edge
       
   767       ///
   410       /// \return the opposite of the given Node on the given Edge
   768       /// \return the opposite of the given Node on the given Edge
   411       ///
       
   412       /// \todo What should we do if given Node and Edge are not incident?
       
   413       Node oppositeNode(Node, UndirEdge) const { return INVALID; }
   769       Node oppositeNode(Node, UndirEdge) const { return INVALID; }
   414 
   770 
   415       /// First node of the undirected edge.
   771       /// \brief First node of the undirected edge.
   416 
   772       ///
   417       /// \return the first node of the given UndirEdge.
   773       /// \return the first node of the given UndirEdge.
   418       ///
   774       ///
   419       /// Naturally undirectected edges don't have direction and thus
   775       /// Naturally undirectected edges don't have direction and thus
   420       /// don't have source and target node. But we use these two methods
   776       /// don't have source and target node. But we use these two methods
   421       /// to query the two endnodes of the edge. The direction of the edge
   777       /// to query the two endnodes of the edge. The direction of the edge
   422       /// which arises this way is called the inherent direction of the
   778       /// which arises this way is called the inherent direction of the
   423       /// undirected edge, and is used to define the "forward" direction
   779       /// undirected edge, and is used to define the "default" direction
   424       /// of the directed versions of the edges.
   780       /// of the directed versions of the edges.
   425       /// \sa forward
   781       /// \sa direction
   426       Node source(UndirEdge) const { return INVALID; }
   782       Node source(UndirEdge) const { return INVALID; }
   427 
   783 
   428       /// Second node of the undirected edge.
   784       /// \brief Second node of the undirected edge.
   429       Node target(UndirEdge) const { return INVALID; }
   785       Node target(UndirEdge) const { return INVALID; }
   430 
   786 
   431       /// Source node of the directed edge.
   787       /// \brief Source node of the directed edge.
   432       Node source(Edge) const { return INVALID; }
   788       Node source(Edge) const { return INVALID; }
   433 
   789 
   434       /// Target node of the directed edge.
   790       /// \brief Target node of the directed edge.
   435       Node target(Edge) const { return INVALID; }
   791       Node target(Edge) const { return INVALID; }
   436 
   792 
   437       /// First node of the graph
   793       /// \brief First node of the graph
   438 
   794       ///
   439       /// \note This method is part of so called \ref
   795       /// \note This method is part of so called \ref
   440       /// developpers_interface "Developpers' interface", so it shouldn't
   796       /// developpers_interface "Developpers' interface", so it shouldn't
   441       /// be used in an end-user program.
   797       /// be used in an end-user program.
   442       void first(Node&) const {}
   798       void first(Node&) const {}
   443       /// Next node of the graph
   799       /// \brief Next node of the graph
   444 
   800       ///
   445       /// \note This method is part of so called \ref
   801       /// \note This method is part of so called \ref
   446       /// developpers_interface "Developpers' interface", so it shouldn't
   802       /// developpers_interface "Developpers' interface", so it shouldn't
   447       /// be used in an end-user program.
   803       /// be used in an end-user program.
   448       void next(Node&) const {}
   804       void next(Node&) const {}
   449 
   805 
   450       /// First undirected edge of the graph
   806       /// \brief First undirected edge of the graph
   451 
   807       ///
   452       /// \note This method is part of so called \ref
   808       /// \note This method is part of so called \ref
   453       /// developpers_interface "Developpers' interface", so it shouldn't
   809       /// developpers_interface "Developpers' interface", so it shouldn't
   454       /// be used in an end-user program.
   810       /// be used in an end-user program.
   455       void first(UndirEdge&) const {}
   811       void first(UndirEdge&) const {}
   456       /// Next undirected edge of the graph
   812       /// \brief Next undirected edge of the graph
   457 
   813       ///
   458       /// \note This method is part of so called \ref
   814       /// \note This method is part of so called \ref
   459       /// developpers_interface "Developpers' interface", so it shouldn't
   815       /// developpers_interface "Developpers' interface", so it shouldn't
   460       /// be used in an end-user program.
   816       /// be used in an end-user program.
   461       void next(UndirEdge&) const {}
   817       void next(UndirEdge&) const {}
   462 
   818 
   463       /// First directed edge of the graph
   819       /// \brief First directed edge of the graph
   464 
   820       ///
   465       /// \note This method is part of so called \ref
   821       /// \note This method is part of so called \ref
   466       /// developpers_interface "Developpers' interface", so it shouldn't
   822       /// developpers_interface "Developpers' interface", so it shouldn't
   467       /// be used in an end-user program.
   823       /// be used in an end-user program.
   468       void first(Edge&) const {}
   824       void first(Edge&) const {}
   469       /// Next directed edge of the graph
   825       /// \brief Next directed edge of the graph
   470 
   826       ///
   471       /// \note This method is part of so called \ref
   827       /// \note This method is part of so called \ref
   472       /// developpers_interface "Developpers' interface", so it shouldn't
   828       /// developpers_interface "Developpers' interface", so it shouldn't
   473       /// be used in an end-user program.
   829       /// be used in an end-user program.
   474       void next(Edge&) const {}
   830       void next(Edge&) const {}
   475 
   831 
   476       /// First outgoing edge from a given node
   832       /// \brief First outgoing edge from a given node
   477 
   833       ///
   478       /// \note This method is part of so called \ref
   834       /// \note This method is part of so called \ref
   479       /// developpers_interface "Developpers' interface", so it shouldn't
   835       /// developpers_interface "Developpers' interface", so it shouldn't
   480       /// be used in an end-user program.
   836       /// be used in an end-user program.
   481       void firstOut(Edge&, Node) const {}
   837       void firstOut(Edge&, Node) const {}
   482       /// Next outgoing edge to a node
   838       /// \brief Next outgoing edge to a node
   483 
   839       ///
   484       /// \note This method is part of so called \ref
   840       /// \note This method is part of so called \ref
   485       /// developpers_interface "Developpers' interface", so it shouldn't
   841       /// developpers_interface "Developpers' interface", so it shouldn't
   486       /// be used in an end-user program.
   842       /// be used in an end-user program.
   487       void nextOut(Edge&) const {}
   843       void nextOut(Edge&) const {}
   488 
   844 
   489       /// First incoming edge to a given node
   845       /// \brief First incoming edge to a given node
   490 
   846       ///
   491       /// \note This method is part of so called \ref
   847       /// \note This method is part of so called \ref
   492       /// developpers_interface "Developpers' interface", so it shouldn't
   848       /// developpers_interface "Developpers' interface", so it shouldn't
   493       /// be used in an end-user program.
   849       /// be used in an end-user program.
   494       void firstIn(Edge&, Node) const {}
   850       void firstIn(Edge&, Node) const {}
   495       /// Next incoming edge to a node
   851       /// \brief Next incoming edge to a node
   496 
   852       ///
   497       /// \note This method is part of so called \ref
   853       /// \note This method is part of so called \ref
   498       /// developpers_interface "Developpers' interface", so it shouldn't
   854       /// developpers_interface "Developpers' interface", so it shouldn't
   499       /// be used in an end-user program.
   855       /// be used in an end-user program.
   500       void nextIn(Edge&) const {}
   856       void nextIn(Edge&) const {}
   501 
   857 
   502 
   858 
   503       /// Base node of the iterator
   859       /// \brief Base node of the iterator
   504       ///
   860       ///
   505       /// Returns the base node (the source in this case) of the iterator
   861       /// Returns the base node (the source in this case) of the iterator
   506       Node baseNode(OutEdgeIt e) const {
   862       Node baseNode(OutEdgeIt e) const {
   507 	return source(e);
   863 	return source(e);
   508       }
   864       }
   509       /// Running node of the iterator
   865       /// \brief Running node of the iterator
   510       ///
   866       ///
   511       /// Returns the running node (the target in this case) of the
   867       /// Returns the running node (the target in this case) of the
   512       /// iterator
   868       /// iterator
   513       Node runningNode(OutEdgeIt e) const {
   869       Node runningNode(OutEdgeIt e) const {
   514 	return target(e);
   870 	return target(e);
   515       }
   871       }
   516 
   872 
   517       /// Base node of the iterator
   873       /// \brief Base node of the iterator
   518       ///
   874       ///
   519       /// Returns the base node (the target in this case) of the iterator
   875       /// Returns the base node (the target in this case) of the iterator
   520       Node baseNode(InEdgeIt e) const {
   876       Node baseNode(InEdgeIt e) const {
   521 	return target(e);
   877 	return target(e);
   522       }
   878       }
   523       /// Running node of the iterator
   879       /// \brief Running node of the iterator
   524       ///
   880       ///
   525       /// Returns the running node (the source in this case) of the
   881       /// Returns the running node (the source in this case) of the
   526       /// iterator
   882       /// iterator
   527       Node runningNode(InEdgeIt e) const {
   883       Node runningNode(InEdgeIt e) const {
   528 	return source(e);
   884 	return source(e);
   529       }
   885       }
   530 
   886 
   531       /// Base node of the iterator
   887       /// \brief Base node of the iterator
   532       ///
   888       ///
   533       /// Returns the base node of the iterator
   889       /// Returns the base node of the iterator
   534       Node baseNode(IncEdgeIt) const {
   890       Node baseNode(IncEdgeIt) const {
   535 	return INVALID;
   891 	return INVALID;
   536       }
   892       }
   537       /// Running node of the iterator
   893       
       
   894       /// \brief Running node of the iterator
   538       ///
   895       ///
   539       /// Returns the running node of the iterator
   896       /// Returns the running node of the iterator
   540       Node runningNode(IncEdgeIt) const {
   897       Node runningNode(IncEdgeIt) const {
   541 	return INVALID;
   898 	return INVALID;
   542       }
   899       }
   543 
       
   544 
   900 
   545       template <typename Graph>
   901       template <typename Graph>
   546       struct Constraints {
   902       struct Constraints {
   547 	void constraints() {
   903 	void constraints() {
   548 	  checkConcept<BaseIterableUndirGraphConcept, Graph>();
   904 	  checkConcept<BaseIterableUndirGraphConcept, Graph>();
   551 	}
   907 	}
   552       };
   908       };
   553 
   909 
   554     };
   910     };
   555 
   911 
       
   912     /// \brief An empty non-static undirected graph class.
       
   913     ///    
       
   914     /// This class provides everything that \ref UndirGraph does.
       
   915     /// Additionally it enables building graphs from scratch.
   556     class ExtendableUndirGraph : public UndirGraph {
   916     class ExtendableUndirGraph : public UndirGraph {
   557     public:
   917     public:
       
   918       
       
   919       /// \brief Add a new node to the graph.
       
   920       ///
       
   921       /// Add a new node to the graph.
       
   922       /// \return the new node.
       
   923       Node addNode();
       
   924 
       
   925       /// \brief Add a new undirected edge to the graph.
       
   926       ///
       
   927       /// Add a new undirected edge to the graph.
       
   928       /// \return the new edge.
       
   929       UndirEdge addEdge(const Node& from, const Node& to);
       
   930 
       
   931       /// \brief Resets the graph.
       
   932       ///
       
   933       /// This function deletes all undirected edges and nodes of the graph.
       
   934       /// It also frees the memory allocated to store them.
       
   935       void clear() { }
   558 
   936 
   559       template <typename Graph>
   937       template <typename Graph>
   560       struct Constraints {
   938       struct Constraints {
   561 	void constraints() {
   939 	void constraints() {
   562 	  checkConcept<BaseIterableUndirGraphConcept, Graph>();
   940 	  checkConcept<BaseIterableUndirGraphConcept, Graph>();
   569 	}
   947 	}
   570       };
   948       };
   571 
   949 
   572     };
   950     };
   573 
   951 
       
   952     /// \brief An empty erasable undirected graph class.
       
   953     ///
       
   954     /// This class is an extension of \ref ExtendableUndirGraph. It makes it
       
   955     /// possible to erase undirected edges or nodes.
   574     class ErasableUndirGraph : public ExtendableUndirGraph {
   956     class ErasableUndirGraph : public ExtendableUndirGraph {
   575     public:
   957     public:
       
   958 
       
   959       /// \brief Deletes a node.
       
   960       ///
       
   961       /// Deletes a node.
       
   962       ///
       
   963       void erase(Node) { }
       
   964       /// \brief Deletes an undirected edge.
       
   965       ///
       
   966       /// Deletes an undirected edge.
       
   967       ///
       
   968       void erase(UndirEdge) { }
   576 
   969 
   577       template <typename Graph>
   970       template <typename Graph>
   578       struct Constraints {
   971       struct Constraints {
   579 	void constraints() {
   972 	void constraints() {
   580 	  checkConcept<ExtendableUndirGraph, Graph>();
   973 	  checkConcept<ExtendableUndirGraph, Graph>();