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