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.
24 ///\author Marton Makai
25 template<typename Graph, typename CapacityMap>
26 void readDimacsMaxFlow(std::istream& is, Graph &g, typename Graph::Node &s, typename Graph::Node &t, CapacityMap& capacity) {
35 typename Graph::Edge e;
36 std::vector<typename Graph::Node> nodes;
42 case 'p': //problem definition
43 is >> problem >> n >> m;
46 for (int k=1; k<=n; ++k) nodes[k]=g.addNode();
48 case 'n': //node definition
49 if (problem=="sp") { //shortest path problem
54 if (problem=="max") { //max flow problem
57 if (d=='s') s=nodes[i];
58 if (d=='t') t=nodes[i];
64 e=g.addEdge(nodes[i], nodes[j]);
74 #endif //HUGO_DIMACS_H