Doc.
authorathos
Mon, 04 Jul 2005 16:11:33 +0000
changeset 1534b86aad11f842
parent 1533 43c7b3085212
child 1535 e667cd5c0886
Doc.
demo/reader_writer_demo.cc
doc/quicktour.dox
lemon/graph_reader.h
lemon/graph_writer.h
     1.1 --- a/demo/reader_writer_demo.cc	Mon Jul 04 16:11:00 2005 +0000
     1.2 +++ b/demo/reader_writer_demo.cc	Mon Jul 04 16:11:33 2005 +0000
     1.3 @@ -24,8 +24,6 @@
     1.4  
     1.5      GraphWriter<SmartGraph> writer(std::cout, graph);
     1.6      writer.writeEdgeMap("multiplicity", cap);
     1.7 -//     writer.writeNode("source", s);
     1.8 -//     writer.writeNode("target", t);
     1.9      writer.run();
    1.10       
    1.11    } catch (DataFormatError& error) {
     2.1 --- a/doc/quicktour.dox	Mon Jul 04 16:11:00 2005 +0000
     2.2 +++ b/doc/quicktour.dox	Mon Jul 04 16:11:33 2005 +0000
     2.3 @@ -38,7 +38,7 @@
     2.4  read a graph (and perhaps maps on it) from a stream (e.g. a file). Of course
     2.5  we also have routines that write a graph (and perhaps maps) to a stream
     2.6  (file): this will also be shown. LEMON supports the DIMACS file formats to
     2.7 -store network optimization problems, but more importantly we also have our own
     2.8 +read network optimization problems, but more importantly we also have our own
     2.9  file format that gives a more flexible way to store data related to network
    2.10  optimization.
    2.11  
    2.12 @@ -86,9 +86,8 @@
    2.13  
    2.14  One can also store network (graph+capacity on the edges) instances and
    2.15  other things (minimum cost flow instances etc.) in DIMACS format and
    2.16 -use these in LEMON: to see the details read the documentation of the
    2.17 -\ref dimacs.h "Dimacs file format reader". There you will also find
    2.18 -the details about the output routines into files of the DIMACS format.
    2.19 +read these in LEMON: to see the details read the documentation of the
    2.20 +\ref dimacs.h "Dimacs file format reader". 
    2.21  
    2.22  </ol>
    2.23  <li> If you want to solve some transportation problems in a network then 
     3.1 --- a/lemon/graph_reader.h	Mon Jul 04 16:11:00 2005 +0000
     3.2 +++ b/lemon/graph_reader.h	Mon Jul 04 16:11:33 2005 +0000
     3.3 @@ -33,6 +33,13 @@
     3.4  
     3.5    /// \brief The graph reader class.
     3.6    ///
     3.7 +  /// The \c GraphReader class provides the graph input. 
     3.8 +  /// Before you read this documentation it might be useful to read the general
     3.9 +  /// description of  \ref graph-io-page "Graph Input-Output".
    3.10 +  /// If you don't need very sophisticated
    3.11 +  /// behaviour then you can use the versions of the public function
    3.12 +  /// \ref readGraph() to read a graph (or a max flow instance etc).
    3.13 +  ///
    3.14    /// The given file format may contain several maps and labeled nodes or 
    3.15    /// edges.
    3.16    ///
    3.17 @@ -332,9 +339,78 @@
    3.18      AttributeReader<ReaderTraits> attribute_reader;
    3.19    };
    3.20  
    3.21 -  /// \brief Read a graph from the input.
    3.22 +
    3.23 +  ///\anchor readGraph()
    3.24    ///
    3.25 -  /// Read a graph from the input.
    3.26 +  /// \brief Read a graph from an input stream.
    3.27 +  ///
    3.28 +  /// Read a graph from an input stream.
    3.29 +  /// \param is The input stream.
    3.30 +  /// \param g The graph.
    3.31 +  template<typename Graph>
    3.32 +  void readGraph(std::istream& is, Graph &g) {
    3.33 +    GraphReader<Graph> reader(is, g);
    3.34 +    reader.run();
    3.35 +  }
    3.36 +
    3.37 +  /// \brief Read a capacitated graph instance from an input stream.
    3.38 +  /// 
    3.39 +  /// Read a capacitated graph (graph+capacity on the
    3.40 +  /// edges) from an input stream.
    3.41 +  /// \param is The input stream.
    3.42 +  /// \param g The graph.
    3.43 +  /// \param capacity The capacity map.
    3.44 +  template<typename Graph, typename CapacityMap>
    3.45 +  void readGraph(std::istream& is, Graph &g, CapacityMap& capacity) {
    3.46 +    GraphReader<Graph> reader(is, g);
    3.47 +    reader.readEdgeMap("capacity", capacity);
    3.48 +    reader.run();
    3.49 +  }
    3.50 +
    3.51 +  /// \brief Read a shortest path instance from an input stream.
    3.52 +  /// 
    3.53 +  /// Read a shortest path instance (graph+capacity on the
    3.54 +  /// edges+designated source) from an input stream.
    3.55 +  /// \param is The input stream.
    3.56 +  /// \param g The graph.
    3.57 +  /// \param capacity The capacity map.
    3.58 +  /// \param s The source node.
    3.59 +  template<typename Graph, typename CapacityMap>
    3.60 +  void readGraph(std::istream& is, Graph &g, CapacityMap& capacity, 
    3.61 +		  typename Graph::Node &s) {
    3.62 +    GraphReader<Graph> reader(is, g);
    3.63 +    reader.readEdgeMap("capacity", capacity);
    3.64 +    reader.readNode("source", s);
    3.65 +    reader.run();
    3.66 +  }
    3.67 +
    3.68 +
    3.69 +
    3.70 +  /// \brief Read a max flow instance from an input stream.
    3.71 +  ///
    3.72 +  /// Read a max flow instance (graph+capacity on the
    3.73 +  /// edges+designated source and target) from an input stream.
    3.74 +  ///
    3.75 +  /// \param is The input stream.
    3.76 +  /// \param g The graph.
    3.77 +  /// \param capacity The capacity map.
    3.78 +  /// \param s The source node.
    3.79 +  /// \param t The target node.
    3.80 +  template<typename Graph, typename CapacityMap>
    3.81 +  void readGraph(std::istream& is, Graph &g, CapacityMap& capacity, 
    3.82 +		  typename Graph::Node &s, typename Graph::Node &t) {
    3.83 +    GraphReader<Graph> reader(is, g);
    3.84 +    reader.readEdgeMap("capacity", capacity);
    3.85 +    reader.readNode("source", s);
    3.86 +    reader.readNode("target", t);
    3.87 +    reader.run();
    3.88 +  }
    3.89 +
    3.90 +  /// \brief Read a min cost flow instance from an input stream.
    3.91 +  ///
    3.92 +  /// Read a min cost flow instance (graph+capacity on the edges+cost
    3.93 +  /// function on the edges+designated source and target) from an input stream.
    3.94 +  ///
    3.95    /// \param is The input stream.
    3.96    /// \param g The graph.
    3.97    /// \param capacity The capacity map.
    3.98 @@ -353,63 +429,6 @@
    3.99      reader.run();
   3.100    }
   3.101  
   3.102 -  /// \brief Read a graph from the input.
   3.103 -  ///
   3.104 -  /// Read a graph from the input.
   3.105 -  /// \param is The input stream.
   3.106 -  /// \param g The graph.
   3.107 -  /// \param capacity The capacity map.
   3.108 -  /// \param s The source node.
   3.109 -  /// \param t The target node.
   3.110 -  template<typename Graph, typename CapacityMap>
   3.111 -  void readGraph(std::istream& is, Graph &g, CapacityMap& capacity, 
   3.112 -		  typename Graph::Node &s, typename Graph::Node &t) {
   3.113 -    GraphReader<Graph> reader(is, g);
   3.114 -    reader.readEdgeMap("capacity", capacity);
   3.115 -    reader.readNode("source", s);
   3.116 -    reader.readNode("target", t);
   3.117 -    reader.run();
   3.118 -  }
   3.119 -
   3.120 -  /// \brief Read a graph from the input.
   3.121 -  ///
   3.122 -  /// Read a graph from the input.
   3.123 -  /// \param is The input stream.
   3.124 -  /// \param g The graph.
   3.125 -  /// \param capacity The capacity map.
   3.126 -  /// \param s The source node.
   3.127 -  template<typename Graph, typename CapacityMap>
   3.128 -  void readGraph(std::istream& is, Graph &g, CapacityMap& capacity, 
   3.129 -		  typename Graph::Node &s) {
   3.130 -    GraphReader<Graph> reader(is, g);
   3.131 -    reader.readEdgeMap("capacity", capacity);
   3.132 -    reader.readNode("source", s);
   3.133 -    reader.run();
   3.134 -  }
   3.135 -
   3.136 -  /// \brief Read a graph from the input.
   3.137 -  ///
   3.138 -  /// Read a graph from the input.
   3.139 -  /// \param is The input stream.
   3.140 -  /// \param g The graph.
   3.141 -  /// \param capacity The capacity map.
   3.142 -  template<typename Graph, typename CapacityMap>
   3.143 -  void readGraph(std::istream& is, Graph &g, CapacityMap& capacity) {
   3.144 -    GraphReader<Graph> reader(is, g);
   3.145 -    reader.readEdgeMap("capacity", capacity);
   3.146 -    reader.run();
   3.147 -  }
   3.148 -
   3.149 -  /// \brief Read a graph from the input.
   3.150 -  ///
   3.151 -  /// Read a graph from the input.
   3.152 -  /// \param is The input stream.
   3.153 -  /// \param g The graph.
   3.154 -  template<typename Graph>
   3.155 -  void readGraph(std::istream& is, Graph &g) {
   3.156 -    GraphReader<Graph> reader(is, g);
   3.157 -    reader.run();
   3.158 -  }
   3.159  
   3.160    /// \brief The undir graph reader class.
   3.161    ///
   3.162 @@ -779,9 +798,22 @@
   3.163      AttributeReader<ReaderTraits> attribute_reader;
   3.164    };
   3.165  
   3.166 -  /// \brief Read an undir graph from the input.
   3.167 +  /// \brief Read an undirected graph from an input stream.
   3.168    ///
   3.169 -  /// Read an undir graph from the input.
   3.170 +  /// Read an undirected graph from an input stream.
   3.171 +  /// \param is The input stream.
   3.172 +  /// \param g The graph.
   3.173 +  template<typename Graph>
   3.174 +  void readUndirGraph(std::istream& is, Graph &g) {
   3.175 +    UndirGraphReader<Graph> reader(is, g);
   3.176 +    reader.run();
   3.177 +  }
   3.178 +
   3.179 +  /// \brief Read an undirected multigraph (undirected graph + capacity
   3.180 +  /// map on the edges) from an input stream.
   3.181 +  ///
   3.182 +  /// Read an undirected multigraph (undirected graph + capacity
   3.183 +  /// map on the edges) from an input stream.
   3.184    /// \param is The input stream.
   3.185    /// \param g The graph.
   3.186    /// \param capacity The capacity map.
   3.187 @@ -792,16 +824,6 @@
   3.188      reader.run();
   3.189    }
   3.190  
   3.191 -  /// \brief Read an undir graph from the input.
   3.192 -  ///
   3.193 -  /// Read an undir graph from the input.
   3.194 -  /// \param is The input stream.
   3.195 -  /// \param g The graph.
   3.196 -  template<typename Graph>
   3.197 -  void readUndirGraph(std::istream& is, Graph &g) {
   3.198 -    UndirGraphReader<Graph> reader(is, g);
   3.199 -    reader.run();
   3.200 -  }
   3.201  
   3.202    /// @}
   3.203  }
     4.1 --- a/lemon/graph_writer.h	Mon Jul 04 16:11:00 2005 +0000
     4.2 +++ b/lemon/graph_writer.h	Mon Jul 04 16:11:33 2005 +0000
     4.3 @@ -17,6 +17,7 @@
     4.4  ///\ingroup io_group
     4.5  ///\file
     4.6  ///\brief Lemon Graph Format writer.
     4.7 +///
     4.8  
     4.9  #ifndef LEMON_GRAPH_WRITER_H
    4.10  #define LEMON_GRAPH_WRITER_H
    4.11 @@ -36,6 +37,10 @@
    4.12    /// The \c GraphWriter class provides the graph output. 
    4.13    /// Before you read this documentation it might be useful to read the general
    4.14    /// description of  \ref graph-io-page "Graph Input-Output".
    4.15 +  /// If you don't need very sophisticated
    4.16 +  /// behaviour then you can use the versions of the public function
    4.17 +  /// \ref writeGraph() to output a graph (or a max flow instance etc).
    4.18 +  ///
    4.19    /// To write a graph
    4.20    /// you should first give writing commands to the writer. You can declare
    4.21    /// write commands as \c NodeMap or \c EdgeMap writing and labeled Node and
    4.22 @@ -276,34 +281,69 @@
    4.23    };
    4.24  
    4.25  
    4.26 +  ///\anchor writeGraph()
    4.27 +  ///
    4.28    /// \brief Write a graph to the output.
    4.29    ///
    4.30    /// Write a graph to the output.
    4.31    /// \param os The output stream.
    4.32    /// \param g The graph.
    4.33 +  template<typename Graph>
    4.34 +  void writeGraph(std::ostream& os, const Graph &g) {
    4.35 +    GraphWriter<Graph> writer(os, g);
    4.36 +    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
    4.37 +    writer.writeNodeMap("id", nodeIdMap);
    4.38 +    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
    4.39 +    writer.writeEdgeMap("id", edgeIdMap);
    4.40 +    writer.run();
    4.41 +  }
    4.42 +
    4.43 +  /// \brief Write a capacitated graph instance to the output.
    4.44 +  /// 
    4.45 +  /// Write a capacitated graph (graph+capacity on the
    4.46 +  /// edges) to the output.
    4.47 +  /// \param os The output stream.
    4.48 +  /// \param g The graph.
    4.49    /// \param capacity The capacity map.
    4.50 -  /// \param s The source node.
    4.51 -  /// \param t The target node.
    4.52 -  /// \param cost The cost map.
    4.53 -  template<typename Graph, typename CapacityMap, typename CostMap>
    4.54 +  template<typename Graph, typename CapacityMap>
    4.55    void writeGraph(std::ostream& os, const Graph &g, 
    4.56 -		  const CapacityMap& capacity, const typename Graph::Node &s,
    4.57 -		  const typename Graph::Node &t, const CostMap& cost) {
    4.58 +		  const CapacityMap& capacity) {
    4.59      GraphWriter<Graph> writer(os, g);
    4.60      IdMap<Graph, typename Graph::Node> nodeIdMap(g);
    4.61      writer.writeNodeMap("id", nodeIdMap);
    4.62      IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
    4.63      writer.writeEdgeMap("id", edgeIdMap);
    4.64      writer.writeEdgeMap("capacity", capacity);
    4.65 -    writer.writeEdgeMap("cost", cost);
    4.66 -    writer.writeNode("source", s);
    4.67 -    writer.writeNode("target", t);
    4.68      writer.run();
    4.69    }
    4.70  
    4.71 -  /// \brief Write a graph to the output.
    4.72 +  /// \brief Write a shortest path instance to the output.
    4.73 +  /// 
    4.74 +  /// Write a shortest path instance (graph+capacity on the
    4.75 +  /// edges+designated source) to the output.
    4.76 +  /// \param os The output stream.
    4.77 +  /// \param g The graph.
    4.78 +  /// \param capacity The capacity map.
    4.79 +  /// \param s The source node.
    4.80 +  template<typename Graph, typename CapacityMap>
    4.81 +  void writeGraph(std::ostream& os, const Graph &g, 
    4.82 +		  const CapacityMap& capacity, const typename Graph::Node &s) {
    4.83 +    GraphWriter<Graph> writer(os, g);
    4.84 +    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
    4.85 +    writer.writeNodeMap("id", nodeIdMap);
    4.86 +    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
    4.87 +    writer.writeEdgeMap("id", edgeIdMap);
    4.88 +    writer.writeEdgeMap("capacity", capacity);
    4.89 +    writer.writeNode("source", s);
    4.90 +    writer.run();
    4.91 +  }
    4.92 +
    4.93 +
    4.94 +  /// \brief Write a max flow instance to the output.
    4.95    ///
    4.96 -  /// Write a graph to the output.
    4.97 +  /// Write a max flow instance (graph+capacity on the
    4.98 +  /// edges+designated source and target) to the output.
    4.99 +  ///
   4.100    /// \param os The output stream.
   4.101    /// \param g The graph.
   4.102    /// \param capacity The capacity map.
   4.103 @@ -324,56 +364,30 @@
   4.104      writer.run();
   4.105    }
   4.106  
   4.107 -  /// \brief Write a graph to the output.
   4.108 +  /// \brief Write a min cost flow instance to the output.
   4.109    ///
   4.110 -  /// Write a graph to the output.
   4.111 +  /// Write a min cost flow instance (graph+capacity on the edges+cost
   4.112 +  /// function on the edges+designated source and target) to the output.
   4.113 +  ///
   4.114    /// \param os The output stream.
   4.115    /// \param g The graph.
   4.116    /// \param capacity The capacity map.
   4.117    /// \param s The source node.
   4.118 -  template<typename Graph, typename CapacityMap>
   4.119 +  /// \param t The target node.
   4.120 +  /// \param cost The cost map.
   4.121 +  template<typename Graph, typename CapacityMap, typename CostMap>
   4.122    void writeGraph(std::ostream& os, const Graph &g, 
   4.123 -		  const CapacityMap& capacity, const typename Graph::Node &s) {
   4.124 +		  const CapacityMap& capacity, const typename Graph::Node &s,
   4.125 +		  const typename Graph::Node &t, const CostMap& cost) {
   4.126      GraphWriter<Graph> writer(os, g);
   4.127      IdMap<Graph, typename Graph::Node> nodeIdMap(g);
   4.128      writer.writeNodeMap("id", nodeIdMap);
   4.129      IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
   4.130      writer.writeEdgeMap("id", edgeIdMap);
   4.131      writer.writeEdgeMap("capacity", capacity);
   4.132 +    writer.writeEdgeMap("cost", cost);
   4.133      writer.writeNode("source", s);
   4.134 -    writer.run();
   4.135 -  }
   4.136 -
   4.137 -  /// \brief Write a graph to the output.
   4.138 -  ///
   4.139 -  /// Write a graph to the output.
   4.140 -  /// \param os The output stream.
   4.141 -  /// \param g The graph.
   4.142 -  /// \param capacity The capacity map.
   4.143 -  template<typename Graph, typename CapacityMap>
   4.144 -  void writeGraph(std::ostream& os, const Graph &g, 
   4.145 -		  const CapacityMap& capacity) {
   4.146 -    GraphWriter<Graph> writer(os, g);
   4.147 -    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
   4.148 -    writer.writeNodeMap("id", nodeIdMap);
   4.149 -    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
   4.150 -    writer.writeEdgeMap("id", edgeIdMap);
   4.151 -    writer.writeEdgeMap("capacity", capacity);
   4.152 -    writer.run();
   4.153 -  }
   4.154 -
   4.155 -  /// \brief Write a graph to the output.
   4.156 -  ///
   4.157 -  /// Write a graph to the output.
   4.158 -  /// \param os The output stream.
   4.159 -  /// \param g The graph.
   4.160 -  template<typename Graph>
   4.161 -  void writeGraph(std::ostream& os, const Graph &g) {
   4.162 -    GraphWriter<Graph> writer(os, g);
   4.163 -    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
   4.164 -    writer.writeNodeMap("id", nodeIdMap);
   4.165 -    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
   4.166 -    writer.writeEdgeMap("id", edgeIdMap);
   4.167 +    writer.writeNode("target", t);
   4.168      writer.run();
   4.169    }
   4.170  
   4.171 @@ -665,6 +679,16 @@
   4.172      AttributeWriter<WriterTraits> attribute_writer;
   4.173    };
   4.174  
   4.175 +  /// \brief Write an undirected graph to the output.
   4.176 +  ///
   4.177 +  /// Write an undirected graph to the output.
   4.178 +  /// \param os The output stream.
   4.179 +  /// \param g The graph.
   4.180 +  template<typename Graph>
   4.181 +  void writeUndirGraph(std::ostream& os, const Graph &g) {
   4.182 +    UndirGraphWriter<Graph> writer(os, g);
   4.183 +    writer.run();
   4.184 +  }
   4.185  
   4.186    /// \brief Write an undirected multigraph (undirected graph + capacity
   4.187    /// map on the edges) to the output.
   4.188 @@ -682,16 +706,6 @@
   4.189      writer.run();
   4.190    }
   4.191  
   4.192 -  /// \brief Write an undirected graph to the output.
   4.193 -  ///
   4.194 -  /// Write an undirected graph to the output.
   4.195 -  /// \param os The output stream.
   4.196 -  /// \param g The graph.
   4.197 -  template<typename Graph>
   4.198 -  void writeUndirGraph(std::ostream& os, const Graph &g) {
   4.199 -    UndirGraphWriter<Graph> writer(os, g);
   4.200 -    writer.run();
   4.201 -  }
   4.202  
   4.203    /// @}
   4.204