demo/circulation_demo.cc
changeset 2536 0a1a6872855c
parent 2391 14a343be7a5a
child 2553 bfced05fa852
equal deleted inserted replaced
1:692ba874bde1 2:e98fcf73d0f8
    50     typedef Graph::NodeMap<double> DNodeMap;
    50     typedef Graph::NodeMap<double> DNodeMap;
    51 
    51 
    52     Graph g;
    52     Graph g;
    53     EdgeMap lo(g);
    53     EdgeMap lo(g);
    54     EdgeMap up(g);
    54     EdgeMap up(g);
    55     EdgeMap x(g);
       
    56     NodeMap delta(g);
    55     NodeMap delta(g);
    57     NodeMap nid(g);
    56     NodeMap nid(g);
    58     EdgeMap eid(g);
    57     EdgeMap eid(g);
    59     DNodeMap cx(g);
    58     DNodeMap cx(g);
    60     DNodeMap cy(g);
    59     DNodeMap cy(g);
    67       readNodeMap("label", nid).
    66       readNodeMap("label", nid).
    68       readNodeMap("coordinates_x", cx).
    67       readNodeMap("coordinates_x", cx).
    69       readNodeMap("coordinates_y", cy).
    68       readNodeMap("coordinates_y", cy).
    70       run();
    69       run();
    71 
    70 
    72     Circulation<Graph,int> gen(g,lo,up,delta,x);
    71     Circulation<Graph> gen(g,lo,up,delta);
    73     int ret=gen.run();
    72     bool ret=gen.run();
    74     if(ret==-1)
    73     if(ret)
    75       {
    74       {
    76 	std::cout << "\nA feasible flow has been found.\n";
    75 	std::cout << "\nA feasible flow has been found.\n";
    77 	if(!gen.checkX(x)) std::cerr << "Oops!!!\n";
    76 	if(!gen.checkFlow()) std::cerr << "Oops!!!\n";
    78 	GraphWriter<Graph>("circulation-output.lgf", g).
    77 	GraphWriter<Graph>("circulation-output.lgf", g).
    79 	  writeEdgeMap("lo_cap", lo).
    78 	  writeEdgeMap("lo_cap", lo).
    80 	  writeEdgeMap("up_cap", up).
    79 	  writeEdgeMap("up_cap", up).
    81 	  writeEdgeMap("flow", x).
    80 	  writeEdgeMap("flow", gen.flowMap()).
    82 	  writeNodeMap("delta", delta).
    81 	  writeNodeMap("delta", delta).
    83 	  writeEdgeMap("label", eid).
    82 	  writeEdgeMap("label", eid).
    84 	  writeNodeMap("label", nid).
    83 	  writeNodeMap("label", nid).
    85 	  writeNodeMap("coordinates_x", cx).
    84 	  writeNodeMap("coordinates_x", cx).
    86 	  writeNodeMap("coordinates_y", cy).
    85 	  writeNodeMap("coordinates_y", cy).
    87 	  run();
    86 	  run();
    88       }
    87       }
    89     else {
    88     else {
    90       std::cout << "\nThere is no such a flow\n";
    89       std::cout << "\nThere is no such a flow\n";
    91       Graph::NodeMap<int> bar(g);
    90       Graph::NodeMap<int> bar(g);
    92       gen.barrier(bar,ret);
    91       gen.barrierMap(bar);
    93       if(!gen.checkBarrier(bar)) std::cerr << "Dual Oops!!!\n";
    92       if(!gen.checkBarrier()) std::cerr << "Dual Oops!!!\n";
    94 
    93 
    95       GraphWriter<Graph>("circulation-output.lgf", g).
    94       GraphWriter<Graph>("circulation-output.lgf", g).
    96 	writeEdgeMap("lo_cap", lo).
    95 	writeEdgeMap("lo_cap", lo).
    97 	writeEdgeMap("up_cap", up).
    96 	writeEdgeMap("up_cap", up).
    98 	writeNodeMap("barrier", bar).
    97 	writeNodeMap("barrier", bar).