demo/dim_to_lgf.cc
changeset 1812 a6f019fa6e7a
parent 1744 51d5d41e15b1
child 1875 98698b69a902
equal deleted inserted replaced
3:3a7c7358266d 4:53a3f1376138
    63 
    63 
    64   typedef Graph::Edge Edge;
    64   typedef Graph::Edge Edge;
    65   typedef Graph::Node Node;
    65   typedef Graph::Node Node;
    66   typedef Graph::EdgeIt EdgeIt;
    66   typedef Graph::EdgeIt EdgeIt;
    67   typedef Graph::NodeIt NodeIt;
    67   typedef Graph::NodeIt NodeIt;
    68   typedef Graph::EdgeMap<string> StringMap;
    68   typedef Graph::EdgeMap<double> DoubleMap;
    69 
    69 
    70   std::string inputName;
    70   std::string inputName;
    71   std::string outputName;
    71   std::string outputName;
    72   std::string typeName;
    72   std::string typeName;
    73 
    73 
   157   }
   157   }
   158 
   158 
   159   if (typeName == "mincostflow") {
   159   if (typeName == "mincostflow") {
   160     Graph graph;
   160     Graph graph;
   161     Node s, t;
   161     Node s, t;
   162     StringMap cost(graph), capacity(graph);
   162     DoubleMap cost(graph), capacity(graph);
   163     readDimacs(is, graph, capacity, s, t, cost);
   163     readDimacs(is, graph, capacity, s, t, cost);
   164     GraphWriter<Graph>(os, graph).
   164     GraphWriter<Graph>(os, graph).
   165       writeEdgeMap("capacity", capacity).
   165       writeEdgeMap("capacity", capacity).
   166       writeNode("source", s).
   166       writeNode("source", s).
   167       writeNode("target", t).
   167       writeNode("target", t).
   168       writeEdgeMap("cost", cost).
   168       writeEdgeMap("cost", cost).
   169       run();
   169       run();
   170   } else if (typeName == "maxflow") {
   170   } else if (typeName == "maxflow") {
   171     Graph graph;
   171     Graph graph;
   172     Node s, t;
   172     Node s, t;
   173     StringMap capacity(graph);
   173     DoubleMap capacity(graph);
   174     readDimacs(is, graph, capacity, s, t);
   174     readDimacs(is, graph, capacity, s, t);
   175     GraphWriter<Graph>(os, graph).
   175     GraphWriter<Graph>(os, graph).
   176       writeEdgeMap("capacity", capacity).
   176       writeEdgeMap("capacity", capacity).
   177       writeNode("source", s).
   177       writeNode("source", s).
   178       writeNode("target", t).
   178       writeNode("target", t).
   179       run();
   179       run();
   180   } else if (typeName == "shortestpath") {
   180   } else if (typeName == "shortestpath") {
   181     Graph graph;
   181     Graph graph;
   182     Node s;
   182     Node s;
   183     StringMap capacity(graph);
   183     DoubleMap capacity(graph);
   184     readDimacs(is, graph, capacity, s);
   184     readDimacs(is, graph, capacity, s);
   185     GraphWriter<Graph>(os, graph).
   185     GraphWriter<Graph>(os, graph).
   186       writeEdgeMap("capacity", capacity).
   186       writeEdgeMap("capacity", capacity).
   187       writeNode("source", s).
   187       writeNode("source", s).
   188       run();
   188       run();
   189   } else if (typeName == "capacitated") {
   189   } else if (typeName == "capacitated") {
   190     Graph graph;
   190     Graph graph;
   191     StringMap capacity(graph);
   191     DoubleMap capacity(graph);
   192     readDimacs(is, graph, capacity);
   192     readDimacs(is, graph, capacity);
   193     GraphWriter<Graph>(os, graph).
   193     GraphWriter<Graph>(os, graph).
   194       writeEdgeMap("capacity", capacity).
   194       writeEdgeMap("capacity", capacity).
   195       run();
   195       run();
   196   } else if (typeName == "plain") {
   196   } else if (typeName == "plain") {