diff -r 8117169c9049 -r f486d30e4e7b src/lemon/graph_writer.h --- a/src/lemon/graph_writer.h Wed Mar 09 14:13:01 2005 +0000 +++ b/src/lemon/graph_writer.h Wed Mar 09 14:15:22 2005 +0000 @@ -27,6 +27,7 @@ #include +#include #include #include @@ -162,7 +163,8 @@ /// Construct a new GraphWriter. It writes from the given map, /// 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) {} /// \brief Destruct the graph writer. @@ -367,9 +369,78 @@ EdgeWriters edge_writers; std::ostream& os; - Graph& graph; + const Graph& graph; }; + /// Ready to use writer function. + template + 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 reader(os, g); + IdMap nodeIdMap(g); + reader.addNodeMap("id", nodeIdMap); + IdMap 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 + void writeGraph(std::ostream& os, const Graph &g, + const CapacityMap& capacity, const typename Graph::Node &s, + const typename Graph::Node &t) { + GraphWriter reader(os, g); + IdMap nodeIdMap(g); + reader.addNodeMap("id", nodeIdMap); + IdMap 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 + void writeGraph(std::ostream& os, const Graph &g, + const CapacityMap& capacity, const typename Graph::Node &s) { + GraphWriter reader(os, g); + IdMap nodeIdMap(g); + reader.addNodeMap("id", nodeIdMap); + IdMap edgeIdMap(g); + reader.addEdgeMap("id", edgeIdMap); + reader.addEdgeMap("capacity", capacity); + reader.addNode("source", s); + reader.run(); + } + /// Ready to use writer function. + template + void writeGraph(std::ostream& os, const Graph &g, + const CapacityMap& capacity) { + GraphWriter reader(os, g); + IdMap nodeIdMap(g); + reader.addNodeMap("id", nodeIdMap); + IdMap edgeIdMap(g); + reader.addEdgeMap("id", edgeIdMap); + reader.addEdgeMap("capacity", capacity); + reader.run(); + } + /// Ready to use writer function. + template + void writeGraph(std::ostream& os, const Graph &g) { + GraphWriter reader(os, g); + IdMap nodeIdMap(g); + reader.addNodeMap("id", nodeIdMap); + IdMap edgeIdMap(g); + reader.addEdgeMap("id", edgeIdMap); + reader.run(); + } + }