src/lemon/graph_writer.h
changeset 1435 8e85e6bbefdf
parent 1434 d8475431bbbb
child 1436 e0beb94d08bf
     1.1 --- a/src/lemon/graph_writer.h	Sat May 21 21:04:57 2005 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,683 +0,0 @@
     1.4 -/* -*- C++ -*-
     1.5 - * src/lemon/graph_writer.h - Part of LEMON, a generic C++ optimization library
     1.6 - *
     1.7 - * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     1.8 - * (Egervary Research Group on Combinatorial Optimization, EGRES).
     1.9 - *
    1.10 - * Permission to use, modify and distribute this software is granted
    1.11 - * provided that this copyright notice appears in all copies. For
    1.12 - * precise terms see the accompanying LICENSE file.
    1.13 - *
    1.14 - * This software is provided "AS IS" with no warranty of any kind,
    1.15 - * express or implied, and with no claim as to its suitability for any
    1.16 - * purpose.
    1.17 - *
    1.18 - */
    1.19 -
    1.20 -///\ingroup io_group
    1.21 -///\file
    1.22 -///\brief Lemon Graph Format writer.
    1.23 -
    1.24 -#ifndef LEMON_GRAPH_WRITER_H
    1.25 -#define LEMON_GRAPH_WRITER_H
    1.26 -
    1.27 -#include <iostream>
    1.28 -
    1.29 -#include <lemon/error.h>
    1.30 -#include <lemon/lemon_writer.h>
    1.31 -
    1.32 -namespace lemon {
    1.33 -
    1.34 -  /// \addtogroup io_group
    1.35 -  /// @{
    1.36 -
    1.37 -  /// \brief The graph writer class.
    1.38 -  ///
    1.39 -  /// The \c GraphWriter class provides the graph output. To write a graph
    1.40 -  /// you should first give writing commands for the writer. You can declare
    1.41 -  /// write command as \c NodeMap or \c EdgeMap writing and labeled Node and
    1.42 -  /// Edge writing.
    1.43 -  ///
    1.44 -  /// \code
    1.45 -  /// GraphWriter<ListGraph> writer(std::cout, graph);
    1.46 -  /// \endcode
    1.47 -  ///
    1.48 -  /// The \c writeNodeMap() function declares a \c NodeMap writing 
    1.49 -  /// command in the \c GraphWriter. You should give as parameter 
    1.50 -  /// the name of the map and the map object. The NodeMap writing 
    1.51 -  /// command with name "id" should write a unique map because it 
    1.52 -  /// is regarded as ID map.
    1.53 -  ///
    1.54 -  /// \code
    1.55 -  /// IdMap<ListGraph, Node> nodeIdMap;
    1.56 -  /// writer.writeNodeMap("id", nodeIdMap);
    1.57 -  ///
    1.58 -  /// writer.writeNodeMap("coords", coords);
    1.59 -  /// writer.writeNodeMap("color", colorMap);
    1.60 -  /// \endcode
    1.61 -  ///
    1.62 -  /// With the \c writeEdgeMap() member function you can give an edge map
    1.63 -  /// writing command similar to the NodeMaps.
    1.64 -  ///
    1.65 -  /// \code
    1.66 -  /// DescriptorMap<ListGraph, Edge, ListGraph::EdgeMap<int> > 
    1.67 -  ///   edgeDescMap(graph);
    1.68 -  /// writer.writeEdgeMap("descriptor", edgeDescMap);
    1.69 -  ///
    1.70 -  /// writer.writeEdgeMap("weight", weightMap);
    1.71 -  /// writer.writeEdgeMap("label", labelMap);
    1.72 -  /// \endcode
    1.73 -  ///
    1.74 -  /// With \c writeNode() and \c writeEdge() functions you can 
    1.75 -  /// point out Nodes and Edges in the graph. By example, you can 
    1.76 -  /// write out the source and target of the graph.
    1.77 -  ///
    1.78 -  /// \code
    1.79 -  /// writer.writeNode("source", sourceNode);
    1.80 -  /// writer.writeNode("target", targetNode);
    1.81 -  ///
    1.82 -  /// writer.writeEdge("observed", edge);
    1.83 -  /// \endcode
    1.84 -  ///
    1.85 -  /// After you give all write commands you must call the \c run() member
    1.86 -  /// function, which execute all the writer commands.
    1.87 -  ///
    1.88 -  /// \code
    1.89 -  /// writer.run();
    1.90 -  /// \endcode
    1.91 -  ///
    1.92 -  /// \see DefaultWriterTraits
    1.93 -  /// \see QuotedStringWriter
    1.94 -  /// \see IdMap
    1.95 -  /// \see DescriptorMap
    1.96 -  /// \see \ref GraphReader
    1.97 -  /// \see \ref graph-io-page
    1.98 -  /// \author Balazs Dezso
    1.99 -  template <typename _Graph, typename _WriterTraits = DefaultWriterTraits> 
   1.100 -  class GraphWriter {
   1.101 -  public:
   1.102 -    
   1.103 -    typedef _Graph Graph;
   1.104 -    typedef typename Graph::Node Node;
   1.105 -    typedef typename Graph::Edge Edge;
   1.106 -
   1.107 -    typedef _WriterTraits WriterTraits;
   1.108 -
   1.109 -    /// \brief Construct a new GraphWriter.
   1.110 -    ///
   1.111 -    /// Construct a new GraphWriter. It writes the given graph
   1.112 -    /// to the given stream.
   1.113 -    GraphWriter(std::ostream& _os, const Graph& _graph) 
   1.114 -      : writer(new LemonWriter(_os)), own_writer(true), 
   1.115 -	nodeset_writer(*writer, _graph, std::string()),
   1.116 -	edgeset_writer(*writer, _graph, nodeset_writer, std::string()),
   1.117 -	node_writer(*writer, nodeset_writer, std::string()),
   1.118 -	edge_writer(*writer, edgeset_writer, std::string()),
   1.119 -	attribute_writer(*writer, std::string()) {}
   1.120 -
   1.121 -    /// \brief Construct a new GraphWriter.
   1.122 -    ///
   1.123 -    /// Construct a new GraphWriter. It writes into the given graph
   1.124 -    /// to the given file.
   1.125 -    GraphWriter(const std::string& _filename, const Graph& _graph) 
   1.126 -      : writer(new LemonWriter(_filename)), own_writer(true), 
   1.127 -	nodeset_writer(*writer, _graph, std::string()),
   1.128 -	edgeset_writer(*writer, _graph, nodeset_writer, std::string()),
   1.129 -	node_writer(*writer, nodeset_writer, std::string()),
   1.130 -	edge_writer(*writer, edgeset_writer, std::string()),
   1.131 -	attribute_writer(*writer, std::string()) {}
   1.132 -
   1.133 -    /// \brief Construct a new GraphWriter.
   1.134 -    ///
   1.135 -    /// Construct a new GraphWriter. It writes into the given graph
   1.136 -    /// to given LemonReader.
   1.137 -    GraphWriter(LemonWriter& _writer, const Graph& _graph)
   1.138 -      : writer(_writer), own_writer(false), 
   1.139 -	nodeset_writer(*writer, _graph, std::string()),
   1.140 -	edgeset_writer(*writer, _graph, nodeset_writer, std::string()),
   1.141 -	node_writer(*writer, nodeset_writer, std::string()),
   1.142 -	edge_writer(*writer, edgeset_writer, std::string()),
   1.143 -	attribute_writer(*writer, std::string()) {}
   1.144 -
   1.145 -    /// \brief Destruct the graph writer.
   1.146 -    ///
   1.147 -    /// Destruct the graph writer.
   1.148 -    ~GraphWriter() {
   1.149 -      if (own_writer) 
   1.150 -	delete writer;
   1.151 -    }
   1.152 -
   1.153 -    /// \brief Add a new node map writer command for the writer.
   1.154 -    ///
   1.155 -    /// Add a new node map writer command for the writer.
   1.156 -    template <typename Map>
   1.157 -    GraphWriter& writeNodeMap(std::string name, const Map& map) {
   1.158 -      nodeset_writer.writeNodeMap(name, map);
   1.159 -      return *this;
   1.160 -    }
   1.161 -
   1.162 -    /// \brief Add a new node map writer command for the writer.
   1.163 -    ///
   1.164 -    /// Add a new node map writer command for the writer.
   1.165 -    template <typename Writer, typename Map>
   1.166 -    GraphWriter& writeNodeMap(std::string name, const Map& map, 
   1.167 -			      const Writer& writer = Writer()) {
   1.168 -      nodeset_writer.writeNodeMap(name, map, writer);
   1.169 -      return *this;
   1.170 -    }
   1.171 -
   1.172 -
   1.173 -    /// \brief Add a new edge map writer command for the writer.
   1.174 -    ///
   1.175 -    /// Add a new edge map writer command for the writer.
   1.176 -    template <typename Map>
   1.177 -    GraphWriter& writeEdgeMap(std::string name, const Map& map) { 
   1.178 -      edgeset_writer.writeEdgeMap(name, map);
   1.179 -      return *this;
   1.180 -    }
   1.181 -
   1.182 -
   1.183 -    /// \brief Add a new edge map writer command for the writer.
   1.184 -    ///
   1.185 -    /// Add a new edge map writer command for the writer.
   1.186 -    template <typename Writer, typename Map>
   1.187 -    GraphWriter& writeEdgeMap(std::string name, const Map& map,
   1.188 -			      const Writer& writer = Writer()) {
   1.189 -      edgeset_writer.writeEdgeMap(name, map, writer);
   1.190 -      return *this;
   1.191 -    }
   1.192 -
   1.193 -    /// \brief Add a new labeled node writer for the writer.
   1.194 -    ///
   1.195 -    /// Add a new labeled node writer for the writer.
   1.196 -    GraphWriter& writeNode(std::string name, const Node& node) {
   1.197 -      node_writer.writeNode(name, node);
   1.198 -      return *this;
   1.199 -    }
   1.200 -
   1.201 -    /// \brief Add a new labeled edge writer for the writer.
   1.202 -    ///
   1.203 -    /// Add a new labeled edge writer for the writer.
   1.204 -    GraphWriter& writeEdge(std::string name, const Edge& edge) {
   1.205 -      edge_writer.writeEdge(name, edge);
   1.206 -    }
   1.207 -
   1.208 -    /// \brief Add a new attribute writer command.
   1.209 -    ///
   1.210 -    ///  Add a new attribute writer command.
   1.211 -    template <typename Value>
   1.212 -    GraphWriter& writeAttribute(std::string name, const Value& value) {
   1.213 -      attribute_writer.writeAttribute(name, value);
   1.214 -      return *this;
   1.215 -    }
   1.216 -    
   1.217 -    /// \brief Add a new attribute writer command.
   1.218 -    ///
   1.219 -    ///  Add a new attribute writer command.
   1.220 -    template <typename Writer, typename Value>
   1.221 -    GraphWriter& writeAttribute(std::string name, const Value& value, 
   1.222 -			       const Writer& writer) {
   1.223 -      attribute_writer.writeAttribute<Writer>(name, value, writer);
   1.224 -      return *this;
   1.225 -    }
   1.226 -
   1.227 -    /// \brief Conversion operator to LemonWriter.
   1.228 -    ///
   1.229 -    /// Conversion operator to LemonWriter. It make possible
   1.230 -    /// to access the encapsulated \e LemonWriter, this way
   1.231 -    /// you can attach to this writer new instances of 
   1.232 -    /// \e LemonWriter::SectionWriter.
   1.233 -    operator LemonWriter&() {
   1.234 -      return *writer;
   1.235 -    }
   1.236 -
   1.237 -    /// \brief Executes the writer commands.
   1.238 -    ///
   1.239 -    /// Executes the writer commands.
   1.240 -    void run() {
   1.241 -      writer->run();
   1.242 -    }
   1.243 -
   1.244 -    /// \brief Write the id of the given node.
   1.245 -    ///
   1.246 -    /// It writes the id of the given node. If there was written an "id"
   1.247 -    /// named node map then it will write the map value belongs to the node.
   1.248 -    void writeId(std::ostream& os, const Node& item) const {
   1.249 -      nodeset_writer.writeId(os, item);
   1.250 -    } 
   1.251 -
   1.252 -    /// \brief Write the id of the given edge.
   1.253 -    ///
   1.254 -    /// It writes the id of the given edge. If there was written an "id"
   1.255 -    /// named edge map then it will write the map value belongs to the edge.
   1.256 -    void writeId(std::ostream& os, const Edge& item) const {
   1.257 -      edgeset_writer.writeId(os, item);
   1.258 -    } 
   1.259 -
   1.260 -  private:
   1.261 -
   1.262 -    LemonWriter* writer;
   1.263 -    bool own_writer;
   1.264 -
   1.265 -    NodeSetWriter<Graph, WriterTraits> nodeset_writer;
   1.266 -    EdgeSetWriter<Graph, WriterTraits> edgeset_writer;
   1.267 -
   1.268 -    NodeWriter<Graph> node_writer;
   1.269 -    EdgeWriter<Graph> edge_writer;
   1.270 -    
   1.271 -    AttributeWriter<WriterTraits> attribute_writer;
   1.272 -  };
   1.273 -
   1.274 -
   1.275 -  /// \brief Write a graph to the output.
   1.276 -  ///
   1.277 -  /// Write a graph to the output.
   1.278 -  /// \param os The output stream.
   1.279 -  /// \param g The graph.
   1.280 -  /// \param capacity The capacity map.
   1.281 -  /// \param s The source node.
   1.282 -  /// \param t The target node.
   1.283 -  /// \param cost The cost map.
   1.284 -  template<typename Graph, typename CapacityMap, typename CostMap>
   1.285 -  void writeGraph(std::ostream& os, const Graph &g, 
   1.286 -		  const CapacityMap& capacity, const typename Graph::Node &s,
   1.287 -		  const typename Graph::Node &t, const CostMap& cost) {
   1.288 -    GraphWriter<Graph> writer(os, g);
   1.289 -    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
   1.290 -    writer.writeNodeMap("id", nodeIdMap);
   1.291 -    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
   1.292 -    writer.writeEdgeMap("id", edgeIdMap);
   1.293 -    writer.writeEdgeMap("capacity", capacity);
   1.294 -    writer.writeEdgeMap("cost", cost);
   1.295 -    writer.writeNode("source", s);
   1.296 -    writer.writeNode("target", t);
   1.297 -    writer.run();
   1.298 -  }
   1.299 -
   1.300 -  /// \brief Write a graph to the output.
   1.301 -  ///
   1.302 -  /// Write a graph to the output.
   1.303 -  /// \param os The output stream.
   1.304 -  /// \param g The graph.
   1.305 -  /// \param capacity The capacity map.
   1.306 -  /// \param s The source node.
   1.307 -  /// \param t The target node.
   1.308 -  template<typename Graph, typename CapacityMap>
   1.309 -  void writeGraph(std::ostream& os, const Graph &g, 
   1.310 -		  const CapacityMap& capacity, const typename Graph::Node &s,
   1.311 -		  const typename Graph::Node &t) {
   1.312 -    GraphWriter<Graph> writer(os, g);
   1.313 -    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
   1.314 -    writer.writeNodeMap("id", nodeIdMap);
   1.315 -    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
   1.316 -    writer.writeEdgeMap("id", edgeIdMap);
   1.317 -    writer.writeEdgeMap("capacity", capacity);
   1.318 -    writer.writeNode("source", s);
   1.319 -    writer.writeNode("target", t);
   1.320 -    writer.run();
   1.321 -  }
   1.322 -
   1.323 -  /// \brief Write a graph to the output.
   1.324 -  ///
   1.325 -  /// Write a graph to the output.
   1.326 -  /// \param os The output stream.
   1.327 -  /// \param g The graph.
   1.328 -  /// \param capacity The capacity map.
   1.329 -  /// \param s The source node.
   1.330 -  template<typename Graph, typename CapacityMap>
   1.331 -  void writeGraph(std::ostream& os, const Graph &g, 
   1.332 -		  const CapacityMap& capacity, const typename Graph::Node &s) {
   1.333 -    GraphWriter<Graph> writer(os, g);
   1.334 -    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
   1.335 -    writer.writeNodeMap("id", nodeIdMap);
   1.336 -    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
   1.337 -    writer.writeEdgeMap("id", edgeIdMap);
   1.338 -    writer.writeEdgeMap("capacity", capacity);
   1.339 -    writer.writeNode("source", s);
   1.340 -    writer.run();
   1.341 -  }
   1.342 -
   1.343 -  /// \brief Write a graph to the output.
   1.344 -  ///
   1.345 -  /// Write a graph to the output.
   1.346 -  /// \param os The output stream.
   1.347 -  /// \param g The graph.
   1.348 -  /// \param capacity The capacity map.
   1.349 -  template<typename Graph, typename CapacityMap>
   1.350 -  void writeGraph(std::ostream& os, const Graph &g, 
   1.351 -		  const CapacityMap& capacity) {
   1.352 -    GraphWriter<Graph> writer(os, g);
   1.353 -    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
   1.354 -    writer.writeNodeMap("id", nodeIdMap);
   1.355 -    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
   1.356 -    writer.writeEdgeMap("id", edgeIdMap);
   1.357 -    writer.writeEdgeMap("capacity", capacity);
   1.358 -    writer.run();
   1.359 -  }
   1.360 -
   1.361 -  /// \brief Write a graph to the output.
   1.362 -  ///
   1.363 -  /// Write a graph to the output.
   1.364 -  /// \param os The output stream.
   1.365 -  /// \param g The graph.
   1.366 -  template<typename Graph>
   1.367 -  void writeGraph(std::ostream& os, const Graph &g) {
   1.368 -    GraphWriter<Graph> writer(os, g);
   1.369 -    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
   1.370 -    writer.writeNodeMap("id", nodeIdMap);
   1.371 -    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
   1.372 -    writer.writeEdgeMap("id", edgeIdMap);
   1.373 -    writer.run();
   1.374 -  }
   1.375 -
   1.376 -  /// \brief The undirected graph writer class.
   1.377 -  ///
   1.378 -  /// The \c UndirGraphWriter class provides the undir graph output. To write 
   1.379 -  /// a graph you should first give writing commands for the writer. You can 
   1.380 -  /// declare write command as \c NodeMap, \c EdgeMap or \c UndirEdgeMap 
   1.381 -  /// writing and labeled Node, Edge or UndirEdge writing.
   1.382 -  ///
   1.383 -  /// \code
   1.384 -  /// UndirGraphWriter<UndirListGraph> writer(std::cout, graph);
   1.385 -  /// \endcode
   1.386 -  ///
   1.387 -  /// The \c writeNodeMap() function declares a \c NodeMap writing 
   1.388 -  /// command in the \c UndirGraphWriter. You should give as parameter 
   1.389 -  /// the name of the map and the map object. The NodeMap writing 
   1.390 -  /// command with name "id" should write a unique map because it 
   1.391 -  /// is regarded as ID map.
   1.392 -  ///
   1.393 -  /// \code
   1.394 -  /// IdMap<UndirListGraph, Node> nodeIdMap;
   1.395 -  /// writer.writeNodeMap("id", nodeIdMap);
   1.396 -  ///
   1.397 -  /// writer.writeNodeMap("coords", coords);
   1.398 -  /// writer.writeNodeMap("color", colorMap);
   1.399 -  /// \endcode
   1.400 -  ///
   1.401 -  /// With the \c writeUndirEdgeMap() member function you can give an 
   1.402 -  /// undirected edge map writing command similar to the NodeMaps.
   1.403 -  ///
   1.404 -  /// \code
   1.405 -  /// DescriptorMap<ListGraph, Edge, ListGraph::EdgeMap<int> > 
   1.406 -  ///   edgeDescMap(graph);
   1.407 -  /// writer.writeUndirEdgeMap("descriptor", edgeDescMap);
   1.408 -  ///
   1.409 -  /// writer.writeUndirEdgeMap("weight", weightMap);
   1.410 -  /// writer.writeUndirEdgeMap("label", labelMap);
   1.411 -  /// \endcode
   1.412 -  /// 
   1.413 -  /// The EdgeMap handling is just a syntactical sugar. It writes
   1.414 -  /// two undirected edge map with '+' and '-' prefix in the name.
   1.415 -  ///
   1.416 -  /// \code
   1.417 -  /// writer.writeEdgeMap("capacity", capacityMap);
   1.418 -  /// \endcode
   1.419 -  ///
   1.420 -  ///
   1.421 -  /// With \c writeNode() and \c writeUndirEdge() functions you can 
   1.422 -  /// point out nodes and undirected edges in the graph. By example, you can 
   1.423 -  /// write out the source and target of the graph.
   1.424 -  ///
   1.425 -  /// \code
   1.426 -  /// writer.writeNode("source", sourceNode);
   1.427 -  /// writer.writeNode("target", targetNode);
   1.428 -  ///
   1.429 -  /// writer.writeUndirEdge("observed", undirEdge);
   1.430 -  /// \endcode
   1.431 -  ///
   1.432 -  /// After you give all write commands you must call the \c run() member
   1.433 -  /// function, which execute all the writer commands.
   1.434 -  ///
   1.435 -  /// \code
   1.436 -  /// writer.run();
   1.437 -  /// \endcode
   1.438 -  ///
   1.439 -  /// \see DefaultWriterTraits
   1.440 -  /// \see QuotedStringWriter
   1.441 -  /// \see IdMap
   1.442 -  /// \see DescriptorMap
   1.443 -  /// \see \ref GraphWriter
   1.444 -  /// \see \ref graph-io-page
   1.445 -  /// \author Balazs Dezso
   1.446 -  template <typename _Graph, typename _WriterTraits = DefaultWriterTraits> 
   1.447 -  class UndirGraphWriter {
   1.448 -  public:
   1.449 -    
   1.450 -    typedef _Graph Graph;
   1.451 -    typedef typename Graph::Node Node;
   1.452 -    typedef typename Graph::Edge Edge;
   1.453 -    typedef typename Graph::UndirEdge UndirEdge;
   1.454 -
   1.455 -    typedef _WriterTraits WriterTraits;
   1.456 -
   1.457 -    /// \brief Construct a new UndirGraphWriter.
   1.458 -    ///
   1.459 -    /// Construct a new UndirGraphWriter. It writes the given graph
   1.460 -    /// to the given stream.
   1.461 -    UndirGraphWriter(std::ostream& _os, const Graph& _graph) 
   1.462 -      : writer(new LemonWriter(_os)), own_writer(true), 
   1.463 -	nodeset_writer(*writer, _graph, std::string()),
   1.464 -	undir_edgeset_writer(*writer, _graph, nodeset_writer, std::string()),
   1.465 -	node_writer(*writer, nodeset_writer, std::string()),
   1.466 -	undir_edge_writer(*writer, undir_edgeset_writer, std::string()),
   1.467 -	attribute_writer(*writer, std::string()) {}
   1.468 -
   1.469 -    /// \brief Construct a new UndirGraphWriter.
   1.470 -    ///
   1.471 -    /// Construct a new UndirGraphWriter. It writes into the given graph
   1.472 -    /// to the given file.
   1.473 -    UndirGraphWriter(const std::string& _filename, const Graph& _graph) 
   1.474 -      : writer(new LemonWriter(_filename)), own_writer(true), 
   1.475 -	nodeset_writer(*writer, _graph, std::string()),
   1.476 -	undir_edgeset_writer(*writer, _graph, nodeset_writer, std::string()),
   1.477 -	node_writer(*writer, nodeset_writer, std::string()),
   1.478 -	undir_edge_writer(*writer, undir_edgeset_writer, std::string()),
   1.479 -	attribute_writer(*writer, std::string()) {}
   1.480 -
   1.481 -    /// \brief Construct a new UndirGraphWriter.
   1.482 -    ///
   1.483 -    /// Construct a new UndirGraphWriter. It writes into the given graph
   1.484 -    /// to given LemonReader.
   1.485 -    UndirGraphWriter(LemonWriter& _writer, const Graph& _graph)
   1.486 -      : writer(_writer), own_writer(false), 
   1.487 -	nodeset_writer(*writer, _graph, std::string()),
   1.488 -	undir_edgeset_writer(*writer, _graph, nodeset_writer, std::string()),
   1.489 -	node_writer(*writer, nodeset_writer, std::string()),
   1.490 -	undir_edge_writer(*writer, undir_edgeset_writer, std::string()),
   1.491 -	attribute_writer(*writer, std::string()) {}
   1.492 -
   1.493 -    /// \brief Destruct the graph writer.
   1.494 -    ///
   1.495 -    /// Destruct the graph writer.
   1.496 -    ~UndirGraphWriter() {
   1.497 -      if (own_writer) 
   1.498 -	delete writer;
   1.499 -    }
   1.500 -
   1.501 -    /// \brief Add a new node map writer command for the writer.
   1.502 -    ///
   1.503 -    /// Add a new node map writer command for the writer.
   1.504 -    template <typename Map>
   1.505 -    UndirGraphWriter& writeNodeMap(std::string name, const Map& map) {
   1.506 -      nodeset_writer.writeNodeMap(name, map);
   1.507 -      return *this;
   1.508 -    }
   1.509 -
   1.510 -    /// \brief Add a new node map writer command for the writer.
   1.511 -    ///
   1.512 -    /// Add a new node map writer command for the writer.
   1.513 -    template <typename Writer, typename Map>
   1.514 -    UndirGraphWriter& writeNodeMap(std::string name, const Map& map, 
   1.515 -			      const Writer& writer = Writer()) {
   1.516 -      nodeset_writer.writeNodeMap(name, map, writer);
   1.517 -      return *this;
   1.518 -    }
   1.519 -
   1.520 -    /// \brief Add a new edge map writer command for the writer.
   1.521 -    ///
   1.522 -    /// Add a new edge map writer command for the writer.
   1.523 -    template <typename Map>
   1.524 -    UndirGraphWriter& writeEdgeMap(std::string name, const Map& map) { 
   1.525 -      undir_edgeset_writer.writeEdgeMap(name, map);
   1.526 -      return *this;
   1.527 -    }
   1.528 -
   1.529 -    /// \brief Add a new edge map writer command for the writer.
   1.530 -    ///
   1.531 -    /// Add a new edge map writer command for the writer.
   1.532 -    template <typename Writer, typename Map>
   1.533 -    UndirGraphWriter& writeEdgeMap(std::string name, const Map& map,
   1.534 -				   const Writer& writer = Writer()) {
   1.535 -      undir_edgeset_writer.writeEdgeMap(name, map, writer);
   1.536 -      return *this;
   1.537 -    }
   1.538 -
   1.539 -    /// \brief Add a new undirected edge map writer command for the writer.
   1.540 -    ///
   1.541 -    /// Add a new undirected edge map writer command for the writer.
   1.542 -    template <typename Map>
   1.543 -    UndirGraphWriter& writeUndirEdgeMap(std::string name, const Map& map) { 
   1.544 -      undir_edgeset_writer.writeUndirEdgeMap(name, map);
   1.545 -      return *this;
   1.546 -    }
   1.547 -
   1.548 -    /// \brief Add a new undirected edge map writer command for the writer.
   1.549 -    ///
   1.550 -    /// Add a new edge undirected map writer command for the writer.
   1.551 -    template <typename Writer, typename Map>
   1.552 -    UndirGraphWriter& writeUndirEdgeMap(std::string name, const Map& map,
   1.553 -					const Writer& writer = Writer()) {
   1.554 -      undir_edgeset_writer.writeUndirEdgeMap(name, map, writer);
   1.555 -      return *this;
   1.556 -    }
   1.557 -
   1.558 -    /// \brief Add a new labeled node writer for the writer.
   1.559 -    ///
   1.560 -    /// Add a new labeled node writer for the writer.
   1.561 -    UndirGraphWriter& writeNode(std::string name, const Node& node) {
   1.562 -      node_writer.writeNode(name, node);
   1.563 -      return *this;
   1.564 -    }
   1.565 -
   1.566 -    /// \brief Add a new labeled edge writer for the writer.
   1.567 -    ///
   1.568 -    /// Add a new labeled edge writer for the writer.
   1.569 -    UndirGraphWriter& writeEdge(std::string name, const Edge& edge) {
   1.570 -      undir_edge_writer.writeEdge(name, edge);
   1.571 -    }
   1.572 -
   1.573 -    /// \brief Add a new labeled undirected edge writer for the writer.
   1.574 -    ///
   1.575 -    /// Add a new labeled undirected edge writer for the writer.
   1.576 -    UndirGraphWriter& writeUndirEdge(std::string name, const UndirEdge& edge) {
   1.577 -      undir_edge_writer.writeUndirEdge(name, edge);
   1.578 -    }
   1.579 -
   1.580 -    /// \brief Add a new attribute writer command.
   1.581 -    ///
   1.582 -    ///  Add a new attribute writer command.
   1.583 -    template <typename Value>
   1.584 -    UndirGraphWriter& writeAttribute(std::string name, const Value& value) {
   1.585 -      attribute_writer.writeAttribute(name, value);
   1.586 -      return *this;
   1.587 -    }
   1.588 -    
   1.589 -    /// \brief Add a new attribute writer command.
   1.590 -    ///
   1.591 -    ///  Add a new attribute writer command.
   1.592 -    template <typename Writer, typename Value>
   1.593 -    UndirGraphWriter& writeAttribute(std::string name, const Value& value, 
   1.594 -			       const Writer& writer) {
   1.595 -      attribute_writer.writeAttribute<Writer>(name, value, writer);
   1.596 -      return *this;
   1.597 -    }
   1.598 -
   1.599 -    /// \brief Conversion operator to LemonWriter.
   1.600 -    ///
   1.601 -    /// Conversion operator to LemonWriter. It make possible
   1.602 -    /// to access the encapsulated \e LemonWriter, this way
   1.603 -    /// you can attach to this writer new instances of 
   1.604 -    /// \e LemonWriter::SectionWriter.
   1.605 -    operator LemonWriter&() {
   1.606 -      return *writer;
   1.607 -    }
   1.608 -
   1.609 -    /// \brief Executes the writer commands.
   1.610 -    ///
   1.611 -    /// Executes the writer commands.
   1.612 -    void run() {
   1.613 -      writer->run();
   1.614 -    }
   1.615 -
   1.616 -    /// \brief Write the id of the given node.
   1.617 -    ///
   1.618 -    /// It writes the id of the given node. If there was written an "id"
   1.619 -    /// named node map then it will write the map value belongs to the node.
   1.620 -    void writeId(std::ostream& os, const Node& item) const {
   1.621 -      nodeset_writer.writeId(os, item);
   1.622 -    } 
   1.623 -
   1.624 -    /// \brief Write the id of the given edge.
   1.625 -    ///
   1.626 -    /// It writes the id of the given edge. If there was written an "id"
   1.627 -    /// named edge map then it will write the map value belongs to the edge.
   1.628 -    void writeId(std::ostream& os, const Edge& item) const {
   1.629 -      undir_edgeset_writer.writeId(os, item);
   1.630 -    } 
   1.631 -
   1.632 -    /// \brief Write the id of the given undirected edge.
   1.633 -    ///
   1.634 -    /// It writes the id of the given undirected edge. If there was written 
   1.635 -    /// an "id" named edge map then it will write the map value belongs to 
   1.636 -    /// the edge.
   1.637 -    void writeId(std::ostream& os, const UndirEdge& item) const {
   1.638 -      undir_edgeset_writer.writeId(os, item);
   1.639 -    } 
   1.640 -
   1.641 -
   1.642 -  private:
   1.643 -
   1.644 -    LemonWriter* writer;
   1.645 -    bool own_writer;
   1.646 -
   1.647 -    NodeSetWriter<Graph, WriterTraits> nodeset_writer;
   1.648 -    UndirEdgeSetWriter<Graph, WriterTraits> undir_edgeset_writer;
   1.649 -
   1.650 -    NodeWriter<Graph> node_writer;
   1.651 -    UndirEdgeWriter<Graph> undir_edge_writer;
   1.652 -    
   1.653 -    AttributeWriter<WriterTraits> attribute_writer;
   1.654 -  };
   1.655 -
   1.656 -
   1.657 -  /// \brief Write an undirected graph to the output.
   1.658 -  ///
   1.659 -  /// Write an undirected graph to the output.
   1.660 -  /// \param os The output stream.
   1.661 -  /// \param g The graph.
   1.662 -  /// \param capacity The capacity undirected map.
   1.663 -  template<typename Graph, typename CapacityMap>
   1.664 -  void writeUndirGraph(std::ostream& os, const Graph &g, 
   1.665 -		       const CapacityMap& capacity) {
   1.666 -    UndirGraphWriter<Graph> writer(os, g);
   1.667 -    writer.writeUndirEdgeMap("capacity", capacity);
   1.668 -    writer.run();
   1.669 -  }
   1.670 -
   1.671 -  /// \brief Write an undirected graph to the output.
   1.672 -  ///
   1.673 -  /// Write an undirected graph to the output.
   1.674 -  /// \param os The output stream.
   1.675 -  /// \param g The graph.
   1.676 -  template<typename Graph>
   1.677 -  void writeUndirGraph(std::ostream& os, const Graph &g) {
   1.678 -    UndirGraphWriter<Graph> writer(os, g);
   1.679 -    writer.run();
   1.680 -  }
   1.681 -
   1.682 -  /// @}
   1.683 -
   1.684 -}
   1.685 -
   1.686 -#endif