// -*- c++ -*- #include #include #include #include #include #include #include using namespace hugo; using std::cout; using std::endl; int main() { leda::graph g; typedef LedaGraph Graph; Graph G(g); // G.addNode(); // G.addNode(); // std::cout << G.nodeNum() << std::endl; typedef Graph::Node Node; typedef Graph::NodeIt NodeIt; typedef Graph::Edge Edge; typedef Graph::EdgeIt EdgeIt; typedef Graph::OutEdgeIt OutEdgeIt; typedef Graph::InEdgeIt InEdgeIt; Node s, t; Graph::EdgeMap cap(G); readDimacsMaxFlow(std::cin, G, s, t, cap); // cout << "bfs and dfs iterator demo on the directed graph" << endl; // for(NodeIt n=G.first(); G.valid(n); G.next(n)) { // cout << G.id(n) << ": "; // cout << "out edges: "; // for(OutEdgeIt e=G.first(n); G.valid(e); G.next(e)) // cout << G.id(G.tail(e)) << "-" << cap.get(e) << "->" << G.id(G.head(e)) << " "; // cout << "in edges: "; // for(InEdgeIt e=G.first(n); G.valid(e); G.next(e)) // cout << G.id(G.tail(e)) << "-" << cap.get(e) << "->" << G.id(G.head(e)) << " "; // cout << endl; // } // int i=0; // for(EdgeIt e=G.first(); G.valid(e); G.next(e)) { cap.set(e, i); i+=3; } // for(EdgeIt e=G.first(); G.valid(e); G.next(e)) { cout << cap.get(e) << " "; } // cout << endl; { //std::cout << "SmartGraph..." << std::endl; std::cout << "on-the-fly edmonds karp demo on wrapped leda graph..." << std::endl; Graph::EdgeMap flow(G); //0 flow Timer ts; ts.reset(); MaxFlow, Graph::EdgeMap > max_flow_test(G, s, t, flow, cap); //max_flow_test.augmentWithBlockingFlow(); int i=0; while (max_flow_test.augmentOnShortestPath()) { // for(EdgeIt e=G.template first(); e.valid(); ++e) { // std::cout<<"("<"<(); e.valid(); ++e) { // std::cout<<"("<"<