123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #include <vector>
- #include <string>
- #include <ostream>
- #include <boost/graph/graph_traits.hpp>
- namespace boost
- {
- template < class Graph, class CapacityMap, class IndexMap >
- void write_dimacs_max_flow(const Graph& g, CapacityMap capacity, IndexMap idx,
- typename graph_traits< Graph >::vertex_descriptor src,
- typename graph_traits< Graph >::vertex_descriptor sink, std::ostream& out)
- {
- typedef typename graph_traits< Graph >::edge_iterator edge_iterator;
- out << "c DIMACS max-flow file generated from boost::write_dimacs_max_flow"
- << std::endl;
- out << "p max " << num_vertices(g) << " " << num_edges(g)
- << std::endl;
-
- out << "n " << get(idx, src) + 1 << " s" << std::endl;
- ;
- out << "n " << get(idx, sink) + 1 << " t"
- << std::endl;
-
- edge_iterator ei, e_end;
- for (boost::tie(ei, e_end) = edges(g); ei != e_end; ++ei)
- {
- out << "a " << idx[source(*ei, g)] + 1 << " " << idx[target(*ei, g)] + 1
- << " " << get(capacity, *ei) << std::endl;
- }
- }
- }
|