11 /// Dimacs flow files.
13 /// This function reads a flow instance from dimacs flow format.
14 /// At the beginning \c g is destroyed by \c g.clear().
15 /// If the data coming from \c is is a max flow innstance, then
16 /// \c s and \t will be respectively the source and target nodes
17 /// and \c capacity will contain the edge capacities.
18 /// If the data is a shortest path problem then \c s will be the
19 /// source node and \capacity will contain the edge lengths.
20 template<typename Graph, typename CapacityMap>
21 void readDimacsMaxFlow(std::istream& is, Graph &g, typename Graph::Node &s, typename Graph::Node &t, CapacityMap& capacity) {
30 typename Graph::Edge e;
31 std::vector<typename Graph::Node> nodes;
37 case 'p': //problem definition
38 is >> problem >> n >> m;
41 for (int k=1; k<=n; ++k) nodes[k]=g.addNode();
43 case 'n': //node definition
44 if (problem=="sp") { //shortest path problem
49 if (problem=="max") { //max flow problem
52 if (d=='s') s=nodes[i];
53 if (d=='t') t=nodes[i];
59 e=g.addEdge(nodes[i], nodes[j]);
69 #endif //HUGO_DIMACS_H