Index: src/lemon/lemon_writer.h
===================================================================
--- src/lemon/lemon_writer.h	(revision 1421)
+++ src/lemon/lemon_writer.h	(revision 1429)
@@ -244,5 +244,5 @@
 
       virtual void write(std::ostream& os, const Item& item) const {
-	return idWriter.writeId(os, item);
+	idWriter.writeId(os, item);
       }
     };
@@ -274,5 +274,5 @@
     typedef _Graph Graph;
     typedef _Traits Traits;
-    typedef typename Graph::Node Item;
+    typedef typename Graph::Node Node;
 
     /// \brief Constructor.
@@ -320,5 +320,5 @@
 			    const Writer& writer = Writer()) {
       writers.push_back(
-	make_pair(name, new MapWriter<Item, Map, Writer>(map, writer)));
+	make_pair(name, new MapWriter<Node, Map, Writer>(map, writer)));
       return *this;
     }
@@ -380,5 +380,5 @@
     /// Otherwise if the \c forceId parameter was true it will write
     /// its id in the graph. 
-    void writeId(std::ostream& os, const Item& item) const {
+    void writeId(std::ostream& os, const Node& item) const {
       if (forceIdMap) {
 	os << graph.id(item);
@@ -390,8 +390,8 @@
   private:
 
-    typedef std::vector<std::pair<std::string, WriterBase<Item>*> > MapWriters;
+    typedef std::vector<std::pair<std::string, WriterBase<Node>*> > MapWriters;
     MapWriters writers;
 
-    WriterBase<Item>* idMap;
+    WriterBase<Node>* idMap;
     bool forceIdMap;
    
@@ -431,5 +431,6 @@
     typedef _Graph Graph;
     typedef _Traits Traits;
-    typedef typename Graph::Edge Item;
+    typedef typename Graph::Node Node;
+    typedef typename Graph::Edge Edge;
 
     /// \brief Constructor.
@@ -447,6 +448,5 @@
       : Parent(_writer), idMap(0), forceIdMap(_forceIdMap),
 	graph(_graph), id(_id),
-	nodeIdWriter(new IdWriter<typename Graph::Node, NodeIdWriter>
-		     (_nodeIdWriter)) {} 
+	nodeIdWriter(new IdWriter<Node, NodeIdWriter>(_nodeIdWriter)) {} 
 
     /// \brief Destructor.
@@ -482,5 +482,5 @@
 			    const Writer& writer = Writer()) {
       writers.push_back(
-	make_pair(name, new MapWriter<Item, Map, Writer>(map, writer)));
+	make_pair(name, new MapWriter<Edge, Map, Writer>(map, writer)));
       return *this;
     }
@@ -547,5 +547,5 @@
     /// Otherwise if the \c forceId parameter was true it will write
     /// its id in the graph. 
-    void writeId(std::ostream& os, const Item& item) const {
+    void writeId(std::ostream& os, const Edge& item) const {
       if (forceIdMap) {
 	os << graph.id(item);
@@ -557,8 +557,8 @@
   private:
 
-    typedef std::vector<std::pair<std::string, WriterBase<Item>*> > MapWriters;
+    typedef std::vector<std::pair<std::string, WriterBase<Edge>*> > MapWriters;
     MapWriters writers;
 
-    WriterBase<Item>* idMap;
+    WriterBase<Edge>* idMap;
     bool forceIdMap;
    
@@ -566,5 +566,5 @@
     std::string id;
 
-    std::auto_ptr<IdWriterBase<typename Graph::Node> > nodeIdWriter;
+    std::auto_ptr<IdWriterBase<Node> > nodeIdWriter;
   };
 
@@ -605,5 +605,7 @@
     typedef _Graph Graph;
     typedef _Traits Traits;
-    typedef typename Graph::UndirEdge Item;
+    typedef typename Graph::Node Node;
+    typedef typename Graph::Edge Edge;
+    typedef typename Graph::UndirEdge UndirEdge;
 
     /// \brief Constructor.
@@ -621,6 +623,5 @@
       : Parent(_writer), idMap(0), forceIdMap(_forceIdMap),
 	graph(_graph), id(_id),
-	nodeIdWriter(new IdWriter<typename Graph::Node, NodeIdWriter>
-		     (_nodeIdWriter)) {} 
+	nodeIdWriter(new IdWriter<Node, NodeIdWriter>(_nodeIdWriter)) {} 
 
     /// \brief Destructor.
@@ -656,5 +657,5 @@
 					  const Writer& writer = Writer()) {
       writers.push_back(
-	make_pair(name, new MapWriter<Item, Map, Writer>(map, writer)));
+	make_pair(name, new MapWriter<UndirEdge, Map, Writer>(map, writer)));
       return *this;
     }
@@ -743,5 +744,5 @@
     /// undirected edge. Otherwise if the \c forceId parameter was true it 
     /// will write its id in the graph. 
-    void writeId(std::ostream& os, const Item& item) const {
+    void writeId(std::ostream& os, const UndirEdge& item) const {
       if (forceIdMap) {
 	os << graph.id(item);
@@ -751,10 +752,31 @@
     } 
 
-  private:
-
-    typedef std::vector<std::pair<std::string, WriterBase<Item>*> > MapWriters;
+    /// \brief Write the id of the given edge.
+    ///
+    /// It writes the id of the given edge. If there was written 
+    /// an "id" named map then it will write the map value belongs to the 
+    /// edge. Otherwise if the \c forceId parameter was true it 
+    /// will write its id in the graph. If the edge is forward map
+    /// then its prefix character is \c '+' elsewhere \c '-'.
+    void writeId(std::ostream& os, const Edge& item) const {
+      if (graph.forward(item)) {
+	os << "+ ";
+      } else {
+	os << "- ";
+      }
+      if (forceIdMap) {
+	os << graph.id(item);
+      } else {
+	idMap->write(os, item);
+      }
+    } 
+
+  private:
+
+    typedef std::vector<std::pair<std::string, 
+				  WriterBase<UndirEdge>*> > MapWriters;
     MapWriters writers;
 
-    WriterBase<Item>* idMap;
+    WriterBase<UndirEdge>* idMap;
     bool forceIdMap;
    
@@ -762,5 +784,5 @@
     std::string id;
 
-    std::auto_ptr<IdWriterBase<typename Graph::Node> > nodeIdWriter;
+    std::auto_ptr<IdWriterBase<Node> > nodeIdWriter;
   };
 
@@ -779,5 +801,5 @@
     typedef CommonSectionWriterBase Parent;
     typedef _Graph Graph;
-    typedef typename Graph::Node Item;
+    typedef typename Graph::Node Node;
   public:
     
@@ -807,5 +829,5 @@
     ///
     /// Add a node writer command for the NodeWriter.
-    void writeNode(const std::string& name, const Item& item) {
+    void writeNode(const std::string& name, const Node& item) {
       writers.push_back(make_pair(name, &item));
     }
@@ -836,7 +858,7 @@
     std::string id;
 
-    typedef std::vector<std::pair<std::string, const Item*> > ItemWriters;
-    ItemWriters writers;
-    std::auto_ptr<IdWriterBase<Item> > idWriter;
+    typedef std::vector<std::pair<std::string, const Node*> > NodeWriters;
+    NodeWriters writers;
+    std::auto_ptr<IdWriterBase<Node> > idWriter;
   };
 
@@ -855,5 +877,5 @@
     typedef CommonSectionWriterBase Parent;
     typedef _Graph Graph;
-    typedef typename Graph::Edge Item;
+    typedef typename Graph::Edge Edge;
   public:
     
@@ -882,5 +904,5 @@
     ///
     /// Add an edge writer command for the EdgeWriter.
-    void writeEdge(const std::string& name, const Item& item) {
+    void writeEdge(const std::string& name, const Edge& item) {
       writers.push_back(make_pair(name, &item));
     }
@@ -911,8 +933,8 @@
     std::string id;
 
-    typedef std::vector<std::pair<std::string, const Item*> > ItemWriters;
-    ItemWriters writers;
-
-    std::auto_ptr<IdWriterBase<Item> > idWriter;
+    typedef std::vector<std::pair<std::string, const Edge*> > EdgeWriters;
+    EdgeWriters writers;
+
+    std::auto_ptr<IdWriterBase<Edge> > idWriter;
   };
 
@@ -931,5 +953,7 @@
     typedef CommonSectionWriterBase Parent;
     typedef _Graph Graph;
-    typedef typename Graph::UndirEdge Item;
+    typedef typename Graph::Node Node;
+    typedef typename Graph::Edge Edge;
+    typedef typename Graph::UndirEdge UndirEdge;
   public:
     
@@ -944,6 +968,6 @@
 	       const std::string& _id = std::string()) 
       : Parent(_writer), id(_id), 
-	idWriter(new IdWriter<typename Graph::UndirEdge, _IdWriter>
-		 (_idWriter)) {} 
+	undirEdgeIdWriter(new IdWriter<UndirEdge, _IdWriter>(_idWriter)),
+	edgeIdWriter(new IdWriter<Edge, _IdWriter>(_idWriter)) {}
 
     /// \brief Destructor.
@@ -957,9 +981,16 @@
   public:
 
+    /// \brief Add an edge writer command for the UndirEdgeWriter.
+    ///
+    /// Add an edge writer command for the UndirEdgeWriter.
+    void writeEdge(const std::string& name, const Edge& item) {
+      edgeWriters.push_back(make_pair(name, &item));
+    }
+
     /// \brief Add an undirected edge writer command for the UndirEdgeWriter.
     ///
-    /// Add an edge writer command for the UndirEdgeWriter.
-    void writeUndirEdge(const std::string& name, const Item& item) {
-      writers.push_back(make_pair(name, &item));
+    /// Add an undirected edge writer command for the UndirEdgeWriter.
+    void writeUndirEdge(const std::string& name, const UndirEdge& item) {
+      undirEdgeWriters.push_back(make_pair(name, &item));
     }
 
@@ -971,5 +1002,5 @@
     /// and the header line's id and the writer's id are the same.
     virtual std::string header() {
-      return "@edges " + id;
+      return "@undiredges " + id;
     }
 
@@ -978,9 +1009,14 @@
     /// Write the content of the section.
     virtual void write(std::ostream& os) {
-      for (int i = 0; i < (int)writers.size(); ++i) {
-	os << writers[i].first << ' ';
-	idWriter->write(os, *(writers[i].second));
+      for (int i = 0; i < (int)undirEdgeWriters.size(); ++i) {
+	os << undirEdgeWriters[i].first << ' ';
+	undirEdgeIdWriter->write(os, *(undirEdgeWriters[i].second));
 	os << std::endl;
       }
+      for (int i = 0; i < (int)edgeWriters.size(); ++i) {
+	os << edgeWriters[i].first << ' ';
+	edgeIdWriter->write(os, *(edgeWriters[i].second));
+	os << std::endl;
+      }
     }
     
@@ -989,8 +1025,13 @@
     std::string id;
 
-    typedef std::vector<std::pair<std::string, const Item*> > ItemWriters;
-    ItemWriters writers;
-
-    std::auto_ptr<IdWriterBase<Item> > idWriter;
+    typedef std::vector<std::pair<std::string, 
+				  const UndirEdge*> > UndirEdgeWriters;
+    UndirEdgeWriters undirEdgeWriters;
+    std::auto_ptr<IdWriterBase<UndirEdge> > undirEdgeIdWriter;
+
+    typedef std::vector<std::pair<std::string, const Edge*> > EdgeWriters;
+    EdgeWriters edgeWriters;
+    std::auto_ptr<IdWriterBase<Edge> > edgeIdWriter;
+
   };
 
