tools/dim_to_lgf.cc
changeset 2415 ef13597d249a
parent 2410 fe46b61da4e3
child 2417 113d381c9160
equal deleted inserted replaced
1:091db9361e4b 2:304fc627268f
    44 
    44 
    45   typedef Graph::Edge Edge;
    45   typedef Graph::Edge Edge;
    46   typedef Graph::Node Node;
    46   typedef Graph::Node Node;
    47   typedef Graph::EdgeIt EdgeIt;
    47   typedef Graph::EdgeIt EdgeIt;
    48   typedef Graph::NodeIt NodeIt;
    48   typedef Graph::NodeIt NodeIt;
    49   typedef Graph::EdgeMap<double> DoubleMap;
    49   typedef Graph::EdgeMap<double> DoubleEdgeMap;
       
    50   typedef Graph::NodeMap<double> DoubleNodeMap;
    50 
    51 
    51   std::string inputName;
    52   std::string inputName;
    52   std::string outputName;
    53   std::string outputName;
    53   std::string typeName;
    54   std::string typeName;
    54 
    55 
   113   }
   114   }
   114   ostream& os = (outputName.empty() ? cout : output);
   115   ostream& os = (outputName.empty() ? cout : output);
   115 
   116 
   116   if (mincostflow) {
   117   if (mincostflow) {
   117     Graph graph;
   118     Graph graph;
   118     Node s, t;
   119     DoubleNodeMap supply(graph);
   119     DoubleMap cost(graph), capacity(graph);
   120     DoubleEdgeMap lower(graph), capacity(graph), cost(graph);
   120     readDimacs(is, graph, capacity, s, t, cost);
   121     readDimacs(is, graph, supply, lower, capacity, cost);
   121     GraphWriter<Graph>(os, graph).
   122     GraphWriter<Graph>(os, graph).
       
   123       writeNodeMap("supply", supply).
       
   124       writeEdgeMap("lower", lower).
   122       writeEdgeMap("capacity", capacity).
   125       writeEdgeMap("capacity", capacity).
   123       writeNode("source", s).
       
   124       writeNode("target", t).
       
   125       writeEdgeMap("cost", cost).
   126       writeEdgeMap("cost", cost).
   126       run();
   127       run();
   127   } else if (maxflow) {
   128   } else if (maxflow) {
   128     Graph graph;
   129     Graph graph;
   129     Node s, t;
   130     Node s, t;
   130     DoubleMap capacity(graph);
   131     DoubleEdgeMap capacity(graph);
   131     readDimacs(is, graph, capacity, s, t);
   132     readDimacs(is, graph, capacity, s, t);
   132     GraphWriter<Graph>(os, graph).
   133     GraphWriter<Graph>(os, graph).
   133       writeEdgeMap("capacity", capacity).
   134       writeEdgeMap("capacity", capacity).
   134       writeNode("source", s).
   135       writeNode("source", s).
   135       writeNode("target", t).
   136       writeNode("target", t).
   136       run();
   137       run();
   137   } else if (shortestpath) {
   138   } else if (shortestpath) {
   138     Graph graph;
   139     Graph graph;
   139     Node s;
   140     Node s;
   140     DoubleMap capacity(graph);
   141     DoubleEdgeMap capacity(graph);
   141     readDimacs(is, graph, capacity, s);
   142     readDimacs(is, graph, capacity, s);
   142     GraphWriter<Graph>(os, graph).
   143     GraphWriter<Graph>(os, graph).
   143       writeEdgeMap("capacity", capacity).
   144       writeEdgeMap("capacity", capacity).
   144       writeNode("source", s).
   145       writeNode("source", s).
   145       run();
   146       run();
   146   } else if (capacitated) {
   147   } else if (capacitated) {
   147     Graph graph;
   148     Graph graph;
   148     DoubleMap capacity(graph);
   149     DoubleEdgeMap capacity(graph);
   149     readDimacs(is, graph, capacity);
   150     readDimacs(is, graph, capacity);
   150     GraphWriter<Graph>(os, graph).
   151     GraphWriter<Graph>(os, graph).
   151       writeEdgeMap("capacity", capacity).
   152       writeEdgeMap("capacity", capacity).
   152       run();
   153       run();
   153   } else if (plain) {
   154   } else if (plain) {