demo/dim_to_lgf.cc
changeset 1756 b1f441f24d08
parent 1641 77f6ab7ad66f
child 1794 79397d64f742
equal deleted inserted replaced
2:9ceb38b56610 3:3a7c7358266d
   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     StringMap cost(graph), capacity(graph);
   163     readDimacs(is, graph, capacity, s, t, cost);
   163     readDimacs(is, graph, capacity, s, t, cost);
   164     writeGraph(os, graph, capacity, s, t, cost);
   164     GraphWriter<Graph>(os, graph).
       
   165       writeEdgeMap("capacity", capacity).
       
   166       writeNode("source", s).
       
   167       writeNode("target", t).
       
   168       writeEdgeMap("cost", cost).
       
   169       run();
   165   } else if (typeName == "maxflow") {
   170   } else if (typeName == "maxflow") {
   166     Graph graph;
   171     Graph graph;
   167     Node s, t;
   172     Node s, t;
   168     StringMap capacity(graph);
   173     StringMap capacity(graph);
   169     readDimacs(is, graph, capacity, s, t);
   174     readDimacs(is, graph, capacity, s, t);
   170     writeGraph(os, graph, capacity, s, t);
   175     GraphWriter<Graph>(os, graph).
       
   176       writeEdgeMap("capacity", capacity).
       
   177       writeNode("source", s).
       
   178       writeNode("target", t).
       
   179       run();
   171   } else if (typeName == "shortestpath") {
   180   } else if (typeName == "shortestpath") {
   172     Graph graph;
   181     Graph graph;
   173     Node s;
   182     Node s;
   174     StringMap capacity(graph);
   183     StringMap capacity(graph);
   175     readDimacs(is, graph, capacity, s);
   184     readDimacs(is, graph, capacity, s);
   176     writeGraph(os, graph, capacity, s);
   185     GraphWriter<Graph>(os, graph).
       
   186       writeEdgeMap("capacity", capacity).
       
   187       writeNode("source", s).
       
   188       run();
   177   } else if (typeName == "capacitated") {
   189   } else if (typeName == "capacitated") {
   178     Graph graph;
   190     Graph graph;
   179     StringMap capacity(graph);
   191     StringMap capacity(graph);
   180     readDimacs(is, graph, capacity);
   192     readDimacs(is, graph, capacity);
   181     writeGraph(os, graph, capacity);
   193     GraphWriter<Graph>(os, graph).
       
   194       writeEdgeMap("capacity", capacity).
       
   195       run();
   182   } else if (typeName == "plain") {
   196   } else if (typeName == "plain") {
   183     Graph graph;
   197     Graph graph;
   184     readDimacs(is, graph);
   198     readDimacs(is, graph);
   185     writeGraph(os, graph);
   199     GraphWriter<Graph>(os, graph).run();
   186   } else {
   200   } else {
   187     cerr << "Invalid type error" << endl;
   201     cerr << "Invalid type error" << endl;
   188     return -1;
   202     return -1;
   189   }
   203   }
   190   return 0;
   204   return 0;