# HG changeset patch # User marci # Date 1082567699 0 # Node ID 749a831c6a8f918c3ecbb9dc1521227bbec28597 # Parent 7a05119c121a468b605fa88e97d7fec18766ad1f dimacs.hh goes to oldies diff -r 7a05119c121a -r 749a831c6a8f src/work/marci/dimacs.hh --- a/src/work/marci/dimacs.hh Wed Apr 21 16:22:50 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -#ifndef DIMACS_HH -#define DIMACS_HH - -#include -#include -#include - -namespace hugo { - - template - void readDimacsMaxFlow(std::istream& is, Graph &G, typename Graph::NodeIt &s, typename Graph::NodeIt &t, CapacityMap& capacity) { - G.clear(); - int cap; - char d; - std::string problem; - char c; - int i, j; - std::string str; - int n, m; - std::vector nodes; - while (is>>c) { - switch (c) { - case 'c': //comment - getline(is, str); - break; - case 't': //type - getline(is, str); - break; - case 'p': //problem definition - is >> problem >> n >> m; - getline(is, str); - nodes.resize(n+1); - for (int k=1; k<=n; ++k) nodes[k]=G.addNode(); - break; - case 'n': //node definition - if (problem=="sp") { //shortest path problem - is >> i; - getline(is, str); - s=nodes[i]; - } - if (problem=="max") { //max flow problem - is >> i >> d; - getline(is, str); - if (d=='s') s=nodes[i]; - if (d=='t') t=nodes[i]; - } - break; - case 'a': - is >> i >> j >> cap; - getline(is, str); - typename Graph::EdgeIt e=G.addEdge(nodes[i], nodes[j]); - capacity.update(); - capacity.set(e, cap); - break; - } - } - } - -} //namespace hugo - -#endif //DIMACS_HH diff -r 7a05119c121a -r 749a831c6a8f src/work/marci/oldies/dimacs.hh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/work/marci/oldies/dimacs.hh Wed Apr 21 17:14:59 2004 +0000 @@ -0,0 +1,61 @@ +#ifndef DIMACS_HH +#define DIMACS_HH + +#include +#include +#include + +namespace hugo { + + template + void readDimacsMaxFlow(std::istream& is, Graph &G, typename Graph::NodeIt &s, typename Graph::NodeIt &t, CapacityMap& capacity) { + G.clear(); + int cap; + char d; + std::string problem; + char c; + int i, j; + std::string str; + int n, m; + std::vector nodes; + while (is>>c) { + switch (c) { + case 'c': //comment + getline(is, str); + break; + case 't': //type + getline(is, str); + break; + case 'p': //problem definition + is >> problem >> n >> m; + getline(is, str); + nodes.resize(n+1); + for (int k=1; k<=n; ++k) nodes[k]=G.addNode(); + break; + case 'n': //node definition + if (problem=="sp") { //shortest path problem + is >> i; + getline(is, str); + s=nodes[i]; + } + if (problem=="max") { //max flow problem + is >> i >> d; + getline(is, str); + if (d=='s') s=nodes[i]; + if (d=='t') t=nodes[i]; + } + break; + case 'a': + is >> i >> j >> cap; + getline(is, str); + typename Graph::EdgeIt e=G.addEdge(nodes[i], nodes[j]); + capacity.update(); + capacity.set(e, cap); + break; + } + } + } + +} //namespace hugo + +#endif //DIMACS_HH