// -*- c++ -*- #include #include #include #include //#include //#include #include #include #include #include #include #include using namespace hugo; int main() { typedef UndirListGraph Graph; typedef Graph::Node Node; typedef Graph::NodeIt NodeIt; typedef Graph::Edge Edge; typedef Graph::EdgeIt EdgeIt; typedef Graph::OutEdgeIt OutEdgeIt; Graph g; //Node s, t; //Graph::EdgeMap cap(g); //readDimacsMaxFlow(std::cin, g, s, t, cap); std::vector s_nodes; std::vector t_nodes; for (int i=0; i<3; ++i) s_nodes.push_back(g.addNode()); for (int i=0; i<3; ++i) t_nodes.push_back(g.addNode()); g.addEdge(s_nodes[0], t_nodes[2]); g.addEdge(t_nodes[1], s_nodes[2]); Graph::NodeMap ref_map(g, -1); IterableBoolMap< Graph::NodeMap > bipartite_map(ref_map); for (int i=0; i<3; ++i) bipartite_map.insert(s_nodes[i], false); for (int i=0; i<3; ++i) bipartite_map.insert(t_nodes[i], true); typedef BipartiteGraphWrapper BGW; BGW bgw(g, bipartite_map); FOR_EACH_LOC(BGW::EdgeIt, e, bgw) { std::cout << bgw.tail(e) << "->" << bgw.head(e) << std::endl; } BGW::NodeMap dbyj(bgw); BGW::EdgeMap dbyxcj(bgw); typedef stGraphWrapper stGW; stGW stgw(bgw); ConstMap const1map(1); stGW::NodeMap ize(stgw); stGW::EdgeMap flow(stgw); BfsIterator< BGW, BGW::NodeMap > bfs(bgw); Graph::NodeIt si; Graph::Node s; s=g.first(si); bfs.pushAndSetReached(BGW::Node(s)); while (!bfs.finished()) ++bfs; BGW::EdgeMap cap(bgw); BGW::EdgeMap flow1(bgw); typedef ResGraphWrapper< BGW, int, BGW::EdgeMap, BGW::EdgeMap > RBGW; RBGW rbgw(bgw, cap, flow1); RBGW::NodeMap u(rbgw); MaxFlow, stGW::EdgeMap > max_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, flow); max_flow_test.augmentOnShortestPath(); return 0; }