1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #include <vector>
- #include <string>
- #include <ostream>
- 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;
- }
- }
- }
|