Index: lemon/concept/undir_graph.h
===================================================================
--- lemon/concept/undir_graph.h	(revision 1624)
+++ lemon/concept/undir_graph.h	(revision 1627)
@@ -120,5 +120,8 @@
 
 	  bool b;
-	  b = graph.forward(e);
+	  b = graph.direction(e);
+	  Edge e = graph.direct(UndirEdge(), true);
+	  e = graph.direct(UndirEdge(), n);
+ 
 	  ignore_unused_variable_warning(b);
 	}
@@ -233,6 +236,10 @@
     /// explanation of this and more see also the page \ref undir_graphs,
     /// a tutorial about undirected graphs.
-
-    class UndirGraph : public StaticGraph {
+    ///
+    /// You can assume that all undirected graph can be handled
+    /// as a static directed graph. This way it is fully conform
+    /// to the StaticGraph concept.
+
+    class UndirGraph {
     public:
       ///\e
@@ -242,6 +249,103 @@
       typedef True UndirTag;
 
+      /// The base type of node iterators, 
+      /// or in other words, the trivial node iterator.
+
+      /// This is the base type of each node iterator,
+      /// thus each kind of node iterator converts to this.
+      /// More precisely each kind of node iterator should be inherited 
+      /// from the trivial node iterator.
+      class Node {
+      public:
+        /// Default constructor
+
+        /// @warning The default constructor sets the iterator
+        /// to an undefined value.
+        Node() { }
+        /// Copy constructor.
+
+        /// Copy constructor.
+        ///
+        Node(const Node&) { }
+
+        /// Invalid constructor \& conversion.
+
+        /// This constructor initializes the iterator to be invalid.
+        /// \sa Invalid for more details.
+        Node(Invalid) { }
+        /// Equality operator
+
+        /// Two iterators are equal if and only if they point to the
+        /// same object or both are invalid.
+        bool operator==(Node) const { return true; }
+
+        /// Inequality operator
+        
+        /// \sa operator==(Node n)
+        ///
+        bool operator!=(Node) const { return true; }
+
+	/// Artificial ordering operator.
+	
+	/// To allow the use of graph descriptors as key type in std::map or
+	/// similar associative container we require this.
+	///
+	/// \note This operator only have to define some strict ordering of
+	/// the items; this order has nothing to do with the iteration
+	/// ordering of the items.
+	///
+	/// \bug This is a technical requirement. Do we really need this?
+	bool operator<(Node) const { return false; }
+
+      };
+    
+      /// This iterator goes through each node.
+
+      /// This iterator goes through each node.
+      /// Its usage is quite simple, for example you can count the number
+      /// of nodes in graph \c g of type \c Graph like this:
+      /// \code
+      /// int count=0;
+      /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
+      /// \endcode
+      class NodeIt : public Node {
+      public:
+        /// Default constructor
+
+        /// @warning The default constructor sets the iterator
+        /// to an undefined value.
+        NodeIt() { }
+        /// Copy constructor.
+        
+        /// Copy constructor.
+        ///
+        NodeIt(const NodeIt& n) : Node(n) { }
+        /// Invalid constructor \& conversion.
+
+        /// Initialize the iterator to be invalid.
+        /// \sa Invalid for more details.
+        NodeIt(Invalid) { }
+        /// Sets the iterator to the first node.
+
+        /// Sets the iterator to the first node of \c g.
+        ///
+        NodeIt(const UndirGraph&) { }
+        /// Node -> NodeIt conversion.
+
+        /// Sets the iterator to the node of \c the graph pointed by 
+	/// the trivial iterator.
+        /// This feature necessitates that each time we 
+        /// iterate the edge-set, the iteration order is the same.
+        NodeIt(const UndirGraph&, const Node&) { }
+        /// Next node.
+
+        /// Assign the iterator to the next node.
+        ///
+        NodeIt& operator++() { return *this; }
+      };
+    
+    
       /// The base type of the undirected edge iterators.
-      
+
       /// The base type of the undirected edge iterators.
       ///
@@ -258,9 +362,4 @@
         ///
         UndirEdge(const UndirEdge&) { }
-        /// Edge -> UndirEdge conversion
-
-        /// Edge -> UndirEdge conversion
-        ///
-        UndirEdge(const Edge&) { }
         /// Initialize the iterator to be invalid.
 
@@ -279,16 +378,22 @@
         bool operator!=(UndirEdge) const { return true; }
 
-	///\e
-
-	///\todo Do we need this?
+	/// Artificial ordering operator.
+	
+	/// To allow the use of graph descriptors as key type in std::map or
+	/// similar associative container we require this.
 	///
-	bool operator<(const UndirEdge &that) const { return true; }
-      };
-    
+	/// \note This operator only have to define some strict ordering of
+	/// the items; this order has nothing to do with the iteration
+	/// ordering of the items.
+	///
+	/// \bug This is a technical requirement. Do we really need this?
+	bool operator<(UndirEdge) const { return false; }
+      };
+
       /// This iterator goes through each undirected edge.
 
       /// This iterator goes through each undirected edge of a graph.
       /// Its usage is quite simple, for example you can count the number
-      /// of edges in a graph \c g of type \c Graph as follows:
+      /// of undirected edges in a graph \c g of type \c Graph as follows:
       /// \code
       /// int count=0;
@@ -298,10 +403,10 @@
       public:
         /// Default constructor
-	
+
         /// @warning The default constructor sets the iterator
         /// to an undefined value.
         UndirEdgeIt() { }
         /// Copy constructor.
-	
+
         /// Copy constructor.
         ///
@@ -312,22 +417,24 @@
         ///
         UndirEdgeIt(Invalid) { }
-        /// This constructor sets the iterator to the first edge.
+        /// This constructor sets the iterator to the first undirected edge.
     
-        /// This constructor sets the iterator to the first edge of \c g.
+        /// This constructor sets the iterator to the first undirected edge.
         UndirEdgeIt(const UndirGraph&) { }
         /// UndirEdge -> UndirEdgeIt conversion
 
-        /// Sets the iterator to the value of the trivial iterator \c e.
-        /// This feature necessitates that each time we 
-        /// iterate the edge-set, the iteration order is the same.
+        /// Sets the iterator to the value of the trivial iterator.
+        /// This feature necessitates that each time we
+        /// iterate the undirected edge-set, the iteration order is the 
+	/// same.
         UndirEdgeIt(const UndirGraph&, const UndirEdge&) { } 
-        ///Next edge
+        /// Next undirected edge
         
-        /// Assign the iterator to the next edge.
+        /// Assign the iterator to the next undirected edge.
         UndirEdgeIt& operator++() { return *this; }
       };
 
-      /// This iterator goes trough the incident undirected edges of a node.
-
+      /// \brief This iterator goes trough the incident undirected 
+      /// edges of a node.
+      ///
       /// This iterator goes trough the incident undirected edges
       /// of a certain node
@@ -376,4 +483,235 @@
       };
 
+      /// The directed edge type.
+
+      /// The directed edge type. It can be converted to the
+      /// undirected edge.
+      class Edge : public UndirEdge {
+      public:
+        /// Default constructor
+
+        /// @warning The default constructor sets the iterator
+        /// to an undefined value.
+        Edge() { }
+        /// Copy constructor.
+
+        /// Copy constructor.
+        ///
+        Edge(const Edge& e) : UndirEdge(e) { }
+        /// Initialize the iterator to be invalid.
+
+        /// Initialize the iterator to be invalid.
+        ///
+        Edge(Invalid) { }
+        /// Equality operator
+
+        /// Two iterators are equal if and only if they point to the
+        /// same object or both are invalid.
+        bool operator==(Edge) const { return true; }
+        /// Inequality operator
+
+        /// \sa operator==(Edge n)
+        ///
+        bool operator!=(Edge) const { return true; }
+
+	/// Artificial ordering operator.
+	
+	/// To allow the use of graph descriptors as key type in std::map or
+	/// similar associative container we require this.
+	///
+	/// \note This operator only have to define some strict ordering of
+	/// the items; this order has nothing to do with the iteration
+	/// ordering of the items.
+	///
+	/// \bug This is a technical requirement. Do we really need this?
+	bool operator<(Edge) const { return false; }
+	
+      }; 
+      /// This iterator goes through each directed edge.
+
+      /// This iterator goes through each edge of a graph.
+      /// Its usage is quite simple, for example you can count the number
+      /// of edges in a graph \c g of type \c Graph as follows:
+      /// \code
+      /// int count=0;
+      /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
+      /// \endcode
+      class EdgeIt : public Edge {
+      public:
+        /// Default constructor
+
+        /// @warning The default constructor sets the iterator
+        /// to an undefined value.
+        EdgeIt() { }
+        /// Copy constructor.
+
+        /// Copy constructor.
+        ///
+        EdgeIt(const EdgeIt& e) : Edge(e) { }
+        /// Initialize the iterator to be invalid.
+
+        /// Initialize the iterator to be invalid.
+        ///
+        EdgeIt(Invalid) { }
+        /// This constructor sets the iterator to the first edge.
+    
+        /// This constructor sets the iterator to the first edge of \c g.
+        ///@param g the graph
+        EdgeIt(const UndirGraph&) { }
+        /// Edge -> EdgeIt conversion
+
+        /// Sets the iterator to the value of the trivial iterator \c e.
+        /// This feature necessitates that each time we 
+        /// iterate the edge-set, the iteration order is the same.
+        EdgeIt(const UndirGraph&, const Edge&) { } 
+        ///Next edge
+        
+        /// Assign the iterator to the next edge.
+        EdgeIt& operator++() { return *this; }
+      };
+   
+      /// This iterator goes trough the outgoing directed edges of a node.
+
+      /// This iterator goes trough the \e outgoing edges of a certain node
+      /// of a graph.
+      /// Its usage is quite simple, for example you can count the number
+      /// of outgoing edges of a node \c n
+      /// in graph \c g of type \c Graph as follows.
+      /// \code
+      /// int count=0;
+      /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count;
+      /// \endcode
+    
+      class OutEdgeIt : public Edge {
+      public:
+        /// Default constructor
+
+        /// @warning The default constructor sets the iterator
+        /// to an undefined value.
+        OutEdgeIt() { }
+        /// Copy constructor.
+
+        /// Copy constructor.
+        ///
+        OutEdgeIt(const OutEdgeIt& e) : Edge(e) { }
+        /// Initialize the iterator to be invalid.
+
+        /// Initialize the iterator to be invalid.
+        ///
+        OutEdgeIt(Invalid) { }
+        /// This constructor sets the iterator to the first outgoing edge.
+    
+        /// This constructor sets the iterator to the first outgoing edge of
+        /// the node.
+        ///@param n the node
+        ///@param g the graph
+        OutEdgeIt(const UndirGraph&, const Node&) { }
+        /// Edge -> OutEdgeIt conversion
+
+        /// Sets the iterator to the value of the trivial iterator.
+	/// This feature necessitates that each time we 
+        /// iterate the edge-set, the iteration order is the same.
+        OutEdgeIt(const UndirGraph&, const Edge&) { }
+        ///Next outgoing edge
+        
+        /// Assign the iterator to the next 
+        /// outgoing edge of the corresponding node.
+        OutEdgeIt& operator++() { return *this; }
+      };
+
+      /// This iterator goes trough the incoming directed edges of a node.
+
+      /// This iterator goes trough the \e incoming edges of a certain node
+      /// of a graph.
+      /// Its usage is quite simple, for example you can count the number
+      /// of outgoing edges of a node \c n
+      /// in graph \c g of type \c Graph as follows.
+      /// \code
+      /// int count=0;
+      /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count;
+      /// \endcode
+
+      class InEdgeIt : public Edge {
+      public:
+        /// Default constructor
+
+        /// @warning The default constructor sets the iterator
+        /// to an undefined value.
+        InEdgeIt() { }
+        /// Copy constructor.
+
+        /// Copy constructor.
+        ///
+        InEdgeIt(const InEdgeIt& e) : Edge(e) { }
+        /// Initialize the iterator to be invalid.
+
+        /// Initialize the iterator to be invalid.
+        ///
+        InEdgeIt(Invalid) { }
+        /// This constructor sets the iterator to first incoming edge.
+    
+        /// This constructor set the iterator to the first incoming edge of
+        /// the node.
+        ///@param n the node
+        ///@param g the graph
+        InEdgeIt(const UndirGraph&, const Node&) { }
+        /// Edge -> InEdgeIt conversion
+
+        /// Sets the iterator to the value of the trivial iterator \c e.
+        /// This feature necessitates that each time we 
+        /// iterate the edge-set, the iteration order is the same.
+        InEdgeIt(const UndirGraph&, const Edge&) { }
+        /// Next incoming edge
+
+        /// Assign the iterator to the next inedge of the corresponding node.
+        ///
+        InEdgeIt& operator++() { return *this; }
+      };
+
+      /// \brief Read write map of the nodes to type \c T.
+      /// 
+      /// ReadWrite map of the nodes to type \c T.
+      /// \sa Reference
+      /// \warning Making maps that can handle bool type (NodeMap<bool>)
+      /// needs some extra attention!
+      template<class T> 
+      class NodeMap : public ReadWriteMap< Node, T >
+      {
+      public:
+
+        ///\e
+        NodeMap(const UndirGraph&) { }
+        ///\e
+        NodeMap(const UndirGraph&, T) { }
+
+        ///Copy constructor
+        NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
+        ///Assignment operator
+        NodeMap& operator=(const NodeMap&) { return *this; }
+        // \todo fix this concept
+      };
+
+      /// \brief Read write map of the directed edges to type \c T.
+      ///
+      /// Reference map of the directed edges to type \c T.
+      /// \sa Reference
+      /// \warning Making maps that can handle bool type (EdgeMap<bool>)
+      /// needs some extra attention!
+      template<class T> 
+      class EdgeMap : public ReadWriteMap<Edge,T>
+      {
+      public:
+
+        ///\e
+        EdgeMap(const UndirGraph&) { }
+        ///\e
+        EdgeMap(const UndirGraph&, T) { }
+        ///Copy constructor
+        EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { }
+        ///Assignment operator
+        EdgeMap& operator=(const EdgeMap&) { return *this; }
+        // \todo fix this concept    
+      };
+
       /// Read write map of the undirected edges to type \c T.
 
@@ -392,5 +730,5 @@
         UndirEdgeMap(const UndirGraph&, T) { }
         ///Copy constructor
-        UndirEdgeMap(const UndirEdgeMap& em) : ReadWriteMap<UndirEdge,T>(em) { }
+        UndirEdgeMap(const UndirEdgeMap& em) : ReadWriteMap<UndirEdge,T>(em) {}
         ///Assignment operator
         UndirEdgeMap &operator=(const UndirEdgeMap&) { return *this; }
@@ -398,21 +736,39 @@
       };
 
-      /// Is the Edge oriented "forward"?
-
+      /// \brief Direct the given undirected edge.
+      ///
+      /// Direct the given undirected edge. The returned edge source
+      /// will be the given edge.
+      Edge direct(const UndirEdge&, const Node&) const {
+	return INVALID;
+      }
+
+      /// \brief Direct the given undirected edge.
+      ///
+      /// Direct the given undirected edge. The returned edge source
+      /// will be the source of the undirected edge if the given bool
+      /// is true.
+      Edge direct(const UndirEdge&, bool) const {
+	return INVALID;
+      }
+
+      /// \brief Returns true if the edge has default orientation.
+      ///
       /// Returns whether the given directed edge is same orientation as
       /// the corresponding undirected edge.
-      ///
-      /// \todo "What does the direction of an undirected edge mean?"
-      bool forward(Edge) const { return true; }
-
-      /// Opposite node on an edge
-
+      bool direction(Edge) const { return true; }
+
+      /// \brief Returns the opposite directed edge.
+      ///
+      /// Returns the opposite directed edge.
+      Edge oppositeEdge(Edge) const { return INVALID; }
+
+      /// \brief Opposite node on an edge
+      ///
       /// \return the opposite of the given Node on the given Edge
-      ///
-      /// \todo What should we do if given Node and Edge are not incident?
       Node oppositeNode(Node, UndirEdge) const { return INVALID; }
 
-      /// First node of the undirected edge.
-
+      /// \brief First node of the undirected edge.
+      ///
       /// \return the first node of the given UndirEdge.
       ///
@@ -421,26 +777,26 @@
       /// to query the two endnodes of the edge. The direction of the edge
       /// which arises this way is called the inherent direction of the
-      /// undirected edge, and is used to define the "forward" direction
+      /// undirected edge, and is used to define the "default" direction
       /// of the directed versions of the edges.
-      /// \sa forward
+      /// \sa direction
       Node source(UndirEdge) const { return INVALID; }
 
-      /// Second node of the undirected edge.
+      /// \brief Second node of the undirected edge.
       Node target(UndirEdge) const { return INVALID; }
 
-      /// Source node of the directed edge.
+      /// \brief Source node of the directed edge.
       Node source(Edge) const { return INVALID; }
 
-      /// Target node of the directed edge.
+      /// \brief Target node of the directed edge.
       Node target(Edge) const { return INVALID; }
 
-      /// First node of the graph
-
+      /// \brief First node of the graph
+      ///
       /// \note This method is part of so called \ref
       /// developpers_interface "Developpers' interface", so it shouldn't
       /// be used in an end-user program.
       void first(Node&) const {}
-      /// Next node of the graph
-
+      /// \brief Next node of the graph
+      ///
       /// \note This method is part of so called \ref
       /// developpers_interface "Developpers' interface", so it shouldn't
@@ -448,12 +804,12 @@
       void next(Node&) const {}
 
-      /// First undirected edge of the graph
-
+      /// \brief First undirected edge of the graph
+      ///
       /// \note This method is part of so called \ref
       /// developpers_interface "Developpers' interface", so it shouldn't
       /// be used in an end-user program.
       void first(UndirEdge&) const {}
-      /// Next undirected edge of the graph
-
+      /// \brief Next undirected edge of the graph
+      ///
       /// \note This method is part of so called \ref
       /// developpers_interface "Developpers' interface", so it shouldn't
@@ -461,12 +817,12 @@
       void next(UndirEdge&) const {}
 
-      /// First directed edge of the graph
-
+      /// \brief First directed edge of the graph
+      ///
       /// \note This method is part of so called \ref
       /// developpers_interface "Developpers' interface", so it shouldn't
       /// be used in an end-user program.
       void first(Edge&) const {}
-      /// Next directed edge of the graph
-
+      /// \brief Next directed edge of the graph
+      ///
       /// \note This method is part of so called \ref
       /// developpers_interface "Developpers' interface", so it shouldn't
@@ -474,12 +830,12 @@
       void next(Edge&) const {}
 
-      /// First outgoing edge from a given node
-
+      /// \brief First outgoing edge from a given node
+      ///
       /// \note This method is part of so called \ref
       /// developpers_interface "Developpers' interface", so it shouldn't
       /// be used in an end-user program.
       void firstOut(Edge&, Node) const {}
-      /// Next outgoing edge to a node
-
+      /// \brief Next outgoing edge to a node
+      ///
       /// \note This method is part of so called \ref
       /// developpers_interface "Developpers' interface", so it shouldn't
@@ -487,12 +843,12 @@
       void nextOut(Edge&) const {}
 
-      /// First incoming edge to a given node
-
+      /// \brief First incoming edge to a given node
+      ///
       /// \note This method is part of so called \ref
       /// developpers_interface "Developpers' interface", so it shouldn't
       /// be used in an end-user program.
       void firstIn(Edge&, Node) const {}
-      /// Next incoming edge to a node
-
+      /// \brief Next incoming edge to a node
+      ///
       /// \note This method is part of so called \ref
       /// developpers_interface "Developpers' interface", so it shouldn't
@@ -501,5 +857,5 @@
 
 
-      /// Base node of the iterator
+      /// \brief Base node of the iterator
       ///
       /// Returns the base node (the source in this case) of the iterator
@@ -507,5 +863,5 @@
 	return source(e);
       }
-      /// Running node of the iterator
+      /// \brief Running node of the iterator
       ///
       /// Returns the running node (the target in this case) of the
@@ -515,5 +871,5 @@
       }
 
-      /// Base node of the iterator
+      /// \brief Base node of the iterator
       ///
       /// Returns the base node (the target in this case) of the iterator
@@ -521,5 +877,5 @@
 	return target(e);
       }
-      /// Running node of the iterator
+      /// \brief Running node of the iterator
       ///
       /// Returns the running node (the source in this case) of the
@@ -529,5 +885,5 @@
       }
 
-      /// Base node of the iterator
+      /// \brief Base node of the iterator
       ///
       /// Returns the base node of the iterator
@@ -535,5 +891,6 @@
 	return INVALID;
       }
-      /// Running node of the iterator
+      
+      /// \brief Running node of the iterator
       ///
       /// Returns the running node of the iterator
@@ -541,5 +898,4 @@
 	return INVALID;
       }
-
 
       template <typename Graph>
@@ -554,6 +910,28 @@
     };
 
+    /// \brief An empty non-static undirected graph class.
+    ///    
+    /// This class provides everything that \ref UndirGraph does.
+    /// Additionally it enables building graphs from scratch.
     class ExtendableUndirGraph : public UndirGraph {
     public:
+      
+      /// \brief Add a new node to the graph.
+      ///
+      /// Add a new node to the graph.
+      /// \return the new node.
+      Node addNode();
+
+      /// \brief Add a new undirected edge to the graph.
+      ///
+      /// Add a new undirected edge to the graph.
+      /// \return the new edge.
+      UndirEdge addEdge(const Node& from, const Node& to);
+
+      /// \brief Resets the graph.
+      ///
+      /// This function deletes all undirected edges and nodes of the graph.
+      /// It also frees the memory allocated to store them.
+      void clear() { }
 
       template <typename Graph>
@@ -572,6 +950,21 @@
     };
 
+    /// \brief An empty erasable undirected graph class.
+    ///
+    /// This class is an extension of \ref ExtendableUndirGraph. It makes it
+    /// possible to erase undirected edges or nodes.
     class ErasableUndirGraph : public ExtendableUndirGraph {
     public:
+
+      /// \brief Deletes a node.
+      ///
+      /// Deletes a node.
+      ///
+      void erase(Node) { }
+      /// \brief Deletes an undirected edge.
+      ///
+      /// Deletes an undirected edge.
+      ///
+      void erase(UndirEdge) { }
 
       template <typename Graph>
