1.1 --- a/lemon/graph_writer.h Mon Jul 04 16:11:00 2005 +0000
1.2 +++ b/lemon/graph_writer.h Mon Jul 04 16:11:33 2005 +0000
1.3 @@ -17,6 +17,7 @@
1.4 ///\ingroup io_group
1.5 ///\file
1.6 ///\brief Lemon Graph Format writer.
1.7 +///
1.8
1.9 #ifndef LEMON_GRAPH_WRITER_H
1.10 #define LEMON_GRAPH_WRITER_H
1.11 @@ -36,6 +37,10 @@
1.12 /// The \c GraphWriter class provides the graph output.
1.13 /// Before you read this documentation it might be useful to read the general
1.14 /// description of \ref graph-io-page "Graph Input-Output".
1.15 + /// If you don't need very sophisticated
1.16 + /// behaviour then you can use the versions of the public function
1.17 + /// \ref writeGraph() to output a graph (or a max flow instance etc).
1.18 + ///
1.19 /// To write a graph
1.20 /// you should first give writing commands to the writer. You can declare
1.21 /// write commands as \c NodeMap or \c EdgeMap writing and labeled Node and
1.22 @@ -276,34 +281,69 @@
1.23 };
1.24
1.25
1.26 + ///\anchor writeGraph()
1.27 + ///
1.28 /// \brief Write a graph to the output.
1.29 ///
1.30 /// Write a graph to the output.
1.31 /// \param os The output stream.
1.32 /// \param g The graph.
1.33 + template<typename Graph>
1.34 + void writeGraph(std::ostream& os, const Graph &g) {
1.35 + GraphWriter<Graph> writer(os, g);
1.36 + IdMap<Graph, typename Graph::Node> nodeIdMap(g);
1.37 + writer.writeNodeMap("id", nodeIdMap);
1.38 + IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
1.39 + writer.writeEdgeMap("id", edgeIdMap);
1.40 + writer.run();
1.41 + }
1.42 +
1.43 + /// \brief Write a capacitated graph instance to the output.
1.44 + ///
1.45 + /// Write a capacitated graph (graph+capacity on the
1.46 + /// edges) to the output.
1.47 + /// \param os The output stream.
1.48 + /// \param g The graph.
1.49 /// \param capacity The capacity map.
1.50 - /// \param s The source node.
1.51 - /// \param t The target node.
1.52 - /// \param cost The cost map.
1.53 - template<typename Graph, typename CapacityMap, typename CostMap>
1.54 + template<typename Graph, typename CapacityMap>
1.55 void writeGraph(std::ostream& os, const Graph &g,
1.56 - const CapacityMap& capacity, const typename Graph::Node &s,
1.57 - const typename Graph::Node &t, const CostMap& cost) {
1.58 + const CapacityMap& capacity) {
1.59 GraphWriter<Graph> writer(os, g);
1.60 IdMap<Graph, typename Graph::Node> nodeIdMap(g);
1.61 writer.writeNodeMap("id", nodeIdMap);
1.62 IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
1.63 writer.writeEdgeMap("id", edgeIdMap);
1.64 writer.writeEdgeMap("capacity", capacity);
1.65 - writer.writeEdgeMap("cost", cost);
1.66 - writer.writeNode("source", s);
1.67 - writer.writeNode("target", t);
1.68 writer.run();
1.69 }
1.70
1.71 - /// \brief Write a graph to the output.
1.72 + /// \brief Write a shortest path instance to the output.
1.73 + ///
1.74 + /// Write a shortest path instance (graph+capacity on the
1.75 + /// edges+designated source) to the output.
1.76 + /// \param os The output stream.
1.77 + /// \param g The graph.
1.78 + /// \param capacity The capacity map.
1.79 + /// \param s The source node.
1.80 + template<typename Graph, typename CapacityMap>
1.81 + void writeGraph(std::ostream& os, const Graph &g,
1.82 + const CapacityMap& capacity, const typename Graph::Node &s) {
1.83 + GraphWriter<Graph> writer(os, g);
1.84 + IdMap<Graph, typename Graph::Node> nodeIdMap(g);
1.85 + writer.writeNodeMap("id", nodeIdMap);
1.86 + IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
1.87 + writer.writeEdgeMap("id", edgeIdMap);
1.88 + writer.writeEdgeMap("capacity", capacity);
1.89 + writer.writeNode("source", s);
1.90 + writer.run();
1.91 + }
1.92 +
1.93 +
1.94 + /// \brief Write a max flow instance to the output.
1.95 ///
1.96 - /// Write a graph to the output.
1.97 + /// Write a max flow instance (graph+capacity on the
1.98 + /// edges+designated source and target) to the output.
1.99 + ///
1.100 /// \param os The output stream.
1.101 /// \param g The graph.
1.102 /// \param capacity The capacity map.
1.103 @@ -324,56 +364,30 @@
1.104 writer.run();
1.105 }
1.106
1.107 - /// \brief Write a graph to the output.
1.108 + /// \brief Write a min cost flow instance to the output.
1.109 ///
1.110 - /// Write a graph to the output.
1.111 + /// Write a min cost flow instance (graph+capacity on the edges+cost
1.112 + /// function on the edges+designated source and target) to the output.
1.113 + ///
1.114 /// \param os The output stream.
1.115 /// \param g The graph.
1.116 /// \param capacity The capacity map.
1.117 /// \param s The source node.
1.118 - template<typename Graph, typename CapacityMap>
1.119 + /// \param t The target node.
1.120 + /// \param cost The cost map.
1.121 + template<typename Graph, typename CapacityMap, typename CostMap>
1.122 void writeGraph(std::ostream& os, const Graph &g,
1.123 - const CapacityMap& capacity, const typename Graph::Node &s) {
1.124 + const CapacityMap& capacity, const typename Graph::Node &s,
1.125 + const typename Graph::Node &t, const CostMap& cost) {
1.126 GraphWriter<Graph> writer(os, g);
1.127 IdMap<Graph, typename Graph::Node> nodeIdMap(g);
1.128 writer.writeNodeMap("id", nodeIdMap);
1.129 IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
1.130 writer.writeEdgeMap("id", edgeIdMap);
1.131 writer.writeEdgeMap("capacity", capacity);
1.132 + writer.writeEdgeMap("cost", cost);
1.133 writer.writeNode("source", s);
1.134 - writer.run();
1.135 - }
1.136 -
1.137 - /// \brief Write a graph to the output.
1.138 - ///
1.139 - /// Write a graph to the output.
1.140 - /// \param os The output stream.
1.141 - /// \param g The graph.
1.142 - /// \param capacity The capacity map.
1.143 - template<typename Graph, typename CapacityMap>
1.144 - void writeGraph(std::ostream& os, const Graph &g,
1.145 - const CapacityMap& capacity) {
1.146 - GraphWriter<Graph> writer(os, g);
1.147 - IdMap<Graph, typename Graph::Node> nodeIdMap(g);
1.148 - writer.writeNodeMap("id", nodeIdMap);
1.149 - IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
1.150 - writer.writeEdgeMap("id", edgeIdMap);
1.151 - writer.writeEdgeMap("capacity", capacity);
1.152 - writer.run();
1.153 - }
1.154 -
1.155 - /// \brief Write a graph to the output.
1.156 - ///
1.157 - /// Write a graph to the output.
1.158 - /// \param os The output stream.
1.159 - /// \param g The graph.
1.160 - template<typename Graph>
1.161 - void writeGraph(std::ostream& os, const Graph &g) {
1.162 - GraphWriter<Graph> writer(os, g);
1.163 - IdMap<Graph, typename Graph::Node> nodeIdMap(g);
1.164 - writer.writeNodeMap("id", nodeIdMap);
1.165 - IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
1.166 - writer.writeEdgeMap("id", edgeIdMap);
1.167 + writer.writeNode("target", t);
1.168 writer.run();
1.169 }
1.170
1.171 @@ -665,6 +679,16 @@
1.172 AttributeWriter<WriterTraits> attribute_writer;
1.173 };
1.174
1.175 + /// \brief Write an undirected graph to the output.
1.176 + ///
1.177 + /// Write an undirected graph to the output.
1.178 + /// \param os The output stream.
1.179 + /// \param g The graph.
1.180 + template<typename Graph>
1.181 + void writeUndirGraph(std::ostream& os, const Graph &g) {
1.182 + UndirGraphWriter<Graph> writer(os, g);
1.183 + writer.run();
1.184 + }
1.185
1.186 /// \brief Write an undirected multigraph (undirected graph + capacity
1.187 /// map on the edges) to the output.
1.188 @@ -682,16 +706,6 @@
1.189 writer.run();
1.190 }
1.191
1.192 - /// \brief Write an undirected graph to the output.
1.193 - ///
1.194 - /// Write an undirected graph to the output.
1.195 - /// \param os The output stream.
1.196 - /// \param g The graph.
1.197 - template<typename Graph>
1.198 - void writeUndirGraph(std::ostream& os, const Graph &g) {
1.199 - UndirGraphWriter<Graph> writer(os, g);
1.200 - writer.run();
1.201 - }
1.202
1.203 /// @}
1.204