10 /// \brief Dimacs file format reader.
14 /// Dimacs flow file format reader function.
16 /// This function reads a flow instance from dimacs flow format.
17 /// At the beginning \c g is cleared by \c g.clear().
18 /// If the data coming from \c is is a max flow problem instance, then
19 /// \c s and \c t will be respectively the source and target nodes
20 /// and \c capacity will contain the edge capacities.
21 /// If the data is a shortest path problem instance then \c s will be the
22 /// source node and \c capacity will contain the edge lengths.
23 template<typename Graph, typename CapacityMap>
24 void readDimacsMaxFlow(std::istream& is, Graph &g, typename Graph::Node &s, typename Graph::Node &t, CapacityMap& capacity) {
33 typename Graph::Edge e;
34 std::vector<typename Graph::Node> nodes;
40 case 'p': //problem definition
41 is >> problem >> n >> m;
44 for (int k=1; k<=n; ++k) nodes[k]=g.addNode();
46 case 'n': //node definition
47 if (problem=="sp") { //shortest path problem
52 if (problem=="max") { //max flow problem
55 if (d=='s') s=nodes[i];
56 if (d=='t') t=nodes[i];
62 e=g.addEdge(nodes[i], nodes[j]);
72 #endif //HUGO_DIMACS_H