Index: lemon/graph_writer.h
===================================================================
--- lemon/graph_writer.h	(revision 1540)
+++ lemon/graph_writer.h	(revision 1744)
@@ -285,112 +285,31 @@
 
 
-  ///\anchor writeGraph()
-  ///
+
   /// \brief Write a graph to the output.
   ///
-  /// Write a graph to the output.
+  /// It is a helper function to write a graph to the given output
+  /// stream. It gives back a GraphWriter object and this object
+  /// can write more maps, labeled nodes and edges and attributes.
+  /// \warning Do not forget to call the \c run() function.
+  ///
   /// \param os The output stream.
   /// \param g The graph.
-  template<typename Graph>
-  void writeGraph(std::ostream& os, const Graph &g) {
-    GraphWriter<Graph> writer(os, g);
-    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
-    writer.writeNodeMap("id", nodeIdMap);
-    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
-    writer.writeEdgeMap("id", edgeIdMap);
-    writer.run();
+  template <typename Graph>
+  GraphWriter<Graph> graphWriter(std::ostream& os, const Graph &g) {
+    return GraphWriter<Graph>(os, g);
   }
 
-  /// \brief Write a capacitated graph instance to the output.
-  /// 
-  /// Write a capacitated graph (graph+capacity on the
-  /// edges) to the output.
-  /// \param os The output stream.
+  /// \brief Write a graph to the output.
+  ///
+  /// It is a helper function to write a graph to the given output
+  /// file. It gives back a GraphWriter object and this object
+  /// can write more maps, labeled nodes and edges and attributes.
+  /// \warning Do not forget to call the \c run() function.
+  ///
+  /// \param fn The filename.
   /// \param g The graph.
-  /// \param capacity The capacity map.
-  template<typename Graph, typename CapacityMap>
-  void writeGraph(std::ostream& os, const Graph &g, 
-		  const CapacityMap& capacity) {
-    GraphWriter<Graph> writer(os, g);
-    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
-    writer.writeNodeMap("id", nodeIdMap);
-    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
-    writer.writeEdgeMap("id", edgeIdMap);
-    writer.writeEdgeMap("capacity", capacity);
-    writer.run();
-  }
-
-  /// \brief Write a shortest path instance to the output.
-  /// 
-  /// Write a shortest path instance (graph+capacity on the
-  /// edges+designated source) to the output.
-  /// \param os The output stream.
-  /// \param g The graph.
-  /// \param capacity The capacity map.
-  /// \param s The source node.
-  template<typename Graph, typename CapacityMap>
-  void writeGraph(std::ostream& os, const Graph &g, 
-		  const CapacityMap& capacity, const typename Graph::Node &s) {
-    GraphWriter<Graph> writer(os, g);
-    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
-    writer.writeNodeMap("id", nodeIdMap);
-    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
-    writer.writeEdgeMap("id", edgeIdMap);
-    writer.writeEdgeMap("capacity", capacity);
-    writer.writeNode("source", s);
-    writer.run();
-  }
-
-
-  /// \brief Write a max flow instance to the output.
-  ///
-  /// Write a max flow instance (graph+capacity on the
-  /// edges+designated source and target) to the output.
-  ///
-  /// \param os The output stream.
-  /// \param g The graph.
-  /// \param capacity The capacity map.
-  /// \param s The source node.
-  /// \param t The target node.
-  template<typename Graph, typename CapacityMap>
-  void writeGraph(std::ostream& os, const Graph &g, 
-		  const CapacityMap& capacity, const typename Graph::Node &s,
-		  const typename Graph::Node &t) {
-    GraphWriter<Graph> writer(os, g);
-    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
-    writer.writeNodeMap("id", nodeIdMap);
-    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
-    writer.writeEdgeMap("id", edgeIdMap);
-    writer.writeEdgeMap("capacity", capacity);
-    writer.writeNode("source", s);
-    writer.writeNode("target", t);
-    writer.run();
-  }
-
-  /// \brief Write a min cost flow instance to the output.
-  ///
-  /// Write a min cost flow instance (graph+capacity on the edges+cost
-  /// function on the edges+designated source and target) to the output.
-  ///
-  /// \param os The output stream.
-  /// \param g The graph.
-  /// \param capacity The capacity map.
-  /// \param s The source node.
-  /// \param t The target node.
-  /// \param cost The cost map.
-  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> writer(os, g);
-    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
-    writer.writeNodeMap("id", nodeIdMap);
-    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
-    writer.writeEdgeMap("id", edgeIdMap);
-    writer.writeEdgeMap("capacity", capacity);
-    writer.writeEdgeMap("cost", cost);
-    writer.writeNode("source", s);
-    writer.writeNode("target", t);
-    writer.run();
+  template <typename Graph>
+  GraphWriter<Graph> graphWriter(const std::string& fn, const Graph &g) {
+    return GraphWriter<Graph>(fn, g);
   }
 
@@ -685,30 +604,33 @@
   /// \brief Write an undirected graph to the output.
   ///
-  /// Write an undirected graph to the output.
+  /// It is a helper function to write an undirected graph to the given output
+  /// stream. It gives back an UndirGraphWriter object and this object
+  /// can write more maps, labeled nodes and edges and attributes.
+  /// \warning Do not forget to call the \c run() function.
+  ///
   /// \param os The output stream.
   /// \param g The graph.
-  template<typename Graph>
-  void writeUndirGraph(std::ostream& os, const Graph &g) {
-    UndirGraphWriter<Graph> writer(os, g);
-    writer.run();
+  template <typename Graph>
+  UndirGraphWriter<Graph> undirGraphWriter(std::ostream& os, const Graph &g) {
+    return UndirGraphWriter<Graph>(os, g);
   }
 
-  /// \brief Write an undirected multigraph (undirected graph + capacity
-  /// map on the edges) to the output.
-  ///
-  /// Write an undirected multigraph (undirected graph + capacity
-  /// map on the edges) to the output.
-  /// \param os The output stream.
+  /// \brief Write an undirected graph to the output.
+  ///
+  /// It is a helper function to write an undirected graph to the given output
+  /// file. It gives back an UndirGraphWriter object and this object
+  /// can write more maps, labeled nodes, edges, undirected edges and 
+  /// attributes.
+  ///
+  /// \warning Do not forget to call the \c run() function.
+  ///
+  /// \param fn The output file.
   /// \param g The graph.
-  /// \param capacity The capacity undirected map.
-  template<typename Graph, typename CapacityMap>
-  void writeUndirGraph(std::ostream& os, const Graph &g, 
-		       const CapacityMap& capacity) {
-    UndirGraphWriter<Graph> writer(os, g);
-    writer.writeUndirEdgeMap("capacity", capacity);
-    writer.run();
+  template <typename Graph>
+  UndirGraphWriter<Graph> undirGraphWriter(const std::string& fn, 
+					   const Graph &g) {
+    return UndirGraphWriter<Graph>(fn, g);
   }
 
-
   /// @}
 
