Index: src/lemon/graph_reader.h
===================================================================
--- src/lemon/graph_reader.h	(revision 1164)
+++ src/lemon/graph_reader.h	(revision 1208)
@@ -36,41 +36,4 @@
   // Exceptions
 
-  class IOException {
-  public:
-    virtual ~IOException() {}
-    virtual string what() const = 0;
-  };
-
-  class DataFormatException : public IOException {
-    std::string message;
-  public:
-    DataFormatException(const std::string& _message) 
-      : message(_message) {}
-    std::string what() const {
-      return "DataFormatException: " + message; 
-    }
-  };
-
-  template <typename _Exception>
-  class StreamException : public _Exception {
-  public:
-    typedef _Exception Exception;
-    StreamException(int _line, Exception _exception) 
-      : Exception(_exception), line_num(_line) {}
-    virtual int line() const {
-      return line_num;
-    }
-
-    virtual ~StreamException() {}
-
-    virtual std::string what() const {
-      ostringstream os;
-      os << Exception::what() << " in line " << line();
-      return os.str();
-    }
-  private:
-    int line_num;
-  };  
-
 
   /// \brief Standard ReaderTraits for the GraphReader class.
@@ -92,5 +55,5 @@
       void read(std::istream& is, Value& value) {
 	if (!(is >> value)) 
-	  throw DataFormatException("Default Reader format exception");
+	  throw DataFormatError("Default reader format exception");
       }
     };
@@ -123,5 +86,5 @@
       is >> ws;
       if (!is.get(c) || c != '\"') 
-	throw DataFormatException("Quoted string format");
+	throw DataFormatError("Quoted string format error");
       while (is.get(c) && c != '\"') {
 	if (escaped && c == '\\') {
@@ -131,5 +94,5 @@
 	}
       }
-      if (!is) throw DataFormatException("Quoted string format");
+      if (!is) throw DataFormatError("Quoted string format error");
     }
 
@@ -165,5 +128,5 @@
 	  int code;
 	  if (!is.get(c) || !isHex(c)) 
-	    throw DataFormatException("Escape format exception");
+	    throw DataFormatError("Escape format error");
 	  else if (code = valueHex(c), !is.get(c) || !isHex(c)) is.putback(c);
 	  else code = code * 16 + valueHex(c);
@@ -174,5 +137,5 @@
 	  int code;
 	  if (!isOct(c)) 
-	    throw DataFormatException("Escape format exception");
+	    throw DataFormatError("Escape format error");
 	  else if (code = valueOct(c), !is.get(c) || !isOct(c)) 
 	    is.putback(c);
@@ -226,7 +189,6 @@
     /// \brief Construct a new GraphReader.
     ///
-    /// Construct a new GraphReader. It reads from the given map,
-    /// it constructs the given map and it use the given reader as the
-    /// default skipper.
+    /// Construct a new GraphReader. It reads into the given graph
+    /// and it use the given reader as the default skipper.
     GraphReader(std::istream& _is, Graph& _graph, 
 		const DefaultReader& _reader = DefaultReader()) 
@@ -266,5 +228,7 @@
 			     const Reader& reader = Reader()) {
       if (node_map_readers.find(name) != node_map_readers.end()) {
-	throw Exception() << "Multiple read rule for node map: " << name;
+	ErrorMessage msg;
+	msg << "Multiple read rule for node map: " << name;
+	throw IOLogicError(msg.message());
       }
       node_map_readers.insert(
@@ -280,5 +244,7 @@
 			     const Reader& reader = Reader()) {
       if (node_map_readers.find(name) != node_map_readers.end()) {
-	throw Exception() << "Multiple read rule for node map: " << name;
+	ErrorMessage msg;
+	msg << "Multiple read rule for node map: " << name;
+	throw IOLogicError(msg.message());
       }
       node_map_readers.insert(
@@ -304,5 +270,7 @@
 			     const Reader& reader = Reader()) {
       if (edge_map_readers.find(name) != edge_map_readers.end()) {
-	throw Exception() << "Multiple read rule for edge map: " << name;
+	ErrorMessage msg;
+	msg << "Multiple read rule for edge map: " << name;
+	throw IOLogicError(msg.message());
       }
       edge_map_readers.insert(
@@ -318,5 +286,7 @@
 			     const Reader& reader = Reader()) {
       if (edge_map_readers.find(name) != edge_map_readers.end()) {
-	throw Exception() << "Multiple read rule for edge map: " << name;
+	ErrorMessage msg;
+	msg << "Multiple read rule for edge map: " << name;
+	throw IOLogicError(msg.message());
       }
       edge_map_readers.insert(
@@ -330,5 +300,7 @@
     GraphReader& addNode(std::string name, Node& node) {
       if (node_readers.find(name) != node_readers.end()) {
-	throw Exception() << "Multiple read rule for node";
+	ErrorMessage msg;
+	msg << "Multiple read rule for node: " << name;
+	throw IOLogicError(msg.message());
       }
       node_readers.insert(make_pair(name, &node));
@@ -341,5 +313,7 @@
     GraphReader& addEdge(std::string name, Edge& edge) {
       if (edge_readers.find(name) != edge_readers.end()) {
-	throw Exception() << "Multiple read rule for edge";
+	ErrorMessage msg;
+	msg << "Multiple read rule for edge: " << name;
+	throw IOLogicError(msg.message());
       }
       edge_readers.insert(make_pair(name, &edge));
@@ -369,8 +343,9 @@
 	}
 	if (line.find("@end") != 0) {
-	  throw DataFormatException("Invalid control sequence: " + line);
-	}
-      } catch (DataFormatException e) {
-	throw StreamException<DataFormatException>(line_num, e);
+	  throw DataFormatError("Invalid control sequence error");
+	}
+      } catch (DataFormatError e) {
+	e.line(line_num);
+	throw e;
       }
     }
@@ -400,5 +375,5 @@
 
       if (index.size() == 0) {
-	throw DataFormatException("No node map found");
+	throw DataFormatError("Cannot find node id map");
       }
 
@@ -437,5 +412,5 @@
 
       if (index.size() == 0) {
-	throw DataFormatException("No edge map found");
+	throw DataFormatError("Cannot find edge id map");
       }
 
@@ -493,5 +468,5 @@
 	}
       }
-      throw DataFormatException("End of stream");
+      throw DataFormatError("End of stream error");
     }
     
@@ -533,5 +508,5 @@
 	  inverse.insert(make_pair(value, item));
 	} else {
-	  throw DataFormatException("Multiple ID occurence");
+	  throw DataFormatError("Multiple ID occurence");
 	}
       }
@@ -544,5 +519,5 @@
 	  return it->second;
 	} else {
-	  throw DataFormatException("Invalid ID");
+	  throw DataFormatError("Invalid ID error");
 	}
       }      
@@ -571,5 +546,5 @@
 	  inverse.insert(make_pair(value, item));
 	} else {
-	  throw DataFormatException("Multiple ID occurence");
+	  throw DataFormatError("Multiple ID occurence error");
 	}
       }
@@ -582,5 +557,5 @@
 	  return it->second;
 	} else {
-	  throw DataFormatException("Invalid ID");
+	  throw DataFormatError("Invalid ID error");
 	}
       }      
@@ -673,3 +648,48 @@
   };
 
+  /// Ready to use reader function.  
+  template<typename Graph, typename CapacityMap, typename CostMap>
+  void readGraph(std::istream& is, Graph &g, CapacityMap& capacity, 
+		  typename Graph::Node &s, typename Graph::Node &t, 
+		  CostMap& cost) {
+    GraphReader<Graph> reader(is, g);
+    reader.addEdgeMap("capacity", capacity);
+    reader.addEdgeMap("cost", cost);
+    reader.addNode("source", s);
+    reader.addNode("target", t);
+    reader.run();
+  }
+
+  template<typename Graph, typename CapacityMap>
+  void readGraph(std::istream& is, Graph &g, CapacityMap& capacity, 
+		  typename Graph::Node &s, typename Graph::Node &t) {
+    GraphReader<Graph> reader(is, g);
+    reader.addEdgeMap("capacity", capacity);
+    reader.addNode("source", s);
+    reader.addNode("target", t);
+    reader.run();
+  }
+
+  template<typename Graph, typename CapacityMap>
+  void readGraph(std::istream& is, Graph &g, CapacityMap& capacity, 
+		  typename Graph::Node &s) {
+    GraphReader<Graph> reader(is, g);
+    reader.addEdgeMap("capacity", capacity);
+    reader.addNode("source", s);
+    reader.run();
+  }
+
+  template<typename Graph, typename CapacityMap>
+  void readGraph(std::istream& is, Graph &g, CapacityMap& capacity) {
+    GraphReader<Graph> reader(is, g);
+    reader.addEdgeMap("capacity", capacity);
+    reader.run();
+  }
+
+  template<typename Graph>
+  void readGraph(std::istream& is, Graph &g) {
+    GraphReader<Graph> reader(is, g);
+    reader.run();
+  }
+
 }
Index: src/lemon/graph_writer.h
===================================================================
--- src/lemon/graph_writer.h	(revision 1188)
+++ src/lemon/graph_writer.h	(revision 1208)
@@ -28,4 +28,5 @@
 #include <memory>
 
+#include <lemon/map_utils.h>
 #include <lemon/invalid.h>
 #include <lemon/error.h>
@@ -163,5 +164,6 @@
     /// it constructs the given map and it use the given writer as the
     /// default skipper.
-    GraphWriter(std::ostream& _os, Graph& _graph) : os(_os), graph(_graph) {}
+    GraphWriter(std::ostream& _os, const Graph& _graph) 
+      : os(_os), graph(_graph) {}
 
 
@@ -368,8 +370,77 @@
 
     std::ostream& os;
-    Graph& graph;
+    const Graph& graph;
 
   };
 
+  /// Ready to use writer function.  
+  template<typename Graph, typename CapacityMap, typename CostMap>
+  void writeGraph(std::ostream& os, const Graph &g, 
+		  const CapacityMap& capacity, const typename Graph::Node &s,
+		  const typename Graph::Node &t, const CostMap& cost) {
+    GraphWriter<Graph> reader(os, g);
+    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
+    reader.addNodeMap("id", nodeIdMap);
+    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
+    reader.addEdgeMap("id", edgeIdMap);
+    reader.addEdgeMap("capacity", capacity);
+    reader.addEdgeMap("cost", cost);
+    reader.addNode("source", s);
+    reader.addNode("target", t);
+    reader.run();
+  }
+
+  /// Ready to use writer function.  
+  template<typename Graph, typename CapacityMap, typename CostMap>
+  void writeGraph(std::ostream& os, const Graph &g, 
+		  const CapacityMap& capacity, const typename Graph::Node &s,
+		  const typename Graph::Node &t) {
+    GraphWriter<Graph> reader(os, g);
+    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
+    reader.addNodeMap("id", nodeIdMap);
+    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
+    reader.addEdgeMap("id", edgeIdMap);
+    reader.addEdgeMap("capacity", capacity);
+    reader.addNode("source", s);
+    reader.addNode("target", t);
+    reader.run();
+  }
+
+  /// Ready to use writer function.  
+  template<typename Graph, typename CapacityMap>
+  void writeGraph(std::ostream& os, const Graph &g, 
+		  const CapacityMap& capacity, const typename Graph::Node &s) {
+    GraphWriter<Graph> reader(os, g);
+    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
+    reader.addNodeMap("id", nodeIdMap);
+    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
+    reader.addEdgeMap("id", edgeIdMap);
+    reader.addEdgeMap("capacity", capacity);
+    reader.addNode("source", s);
+    reader.run();
+  }
+  /// Ready to use writer function.  
+  template<typename Graph, typename CapacityMap>
+  void writeGraph(std::ostream& os, const Graph &g, 
+		  const CapacityMap& capacity) {
+    GraphWriter<Graph> reader(os, g);
+    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
+    reader.addNodeMap("id", nodeIdMap);
+    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
+    reader.addEdgeMap("id", edgeIdMap);
+    reader.addEdgeMap("capacity", capacity);
+    reader.run();
+  }
+  /// Ready to use writer function.  
+  template<typename Graph>
+  void writeGraph(std::ostream& os, const Graph &g) {
+    GraphWriter<Graph> reader(os, g);
+    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
+    reader.addNodeMap("id", nodeIdMap);
+    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
+    reader.addEdgeMap("id", edgeIdMap);
+    reader.run();
+  }
+
 
 }
