athos@36: #include athos@36: #include athos@36: #include athos@36: athos@36: #include "marci_list_graph.hh" athos@36: #include "marci_graph_traits.hh" athos@36: #include "marci_property_vector.hh" athos@36: #include "preflow_push.hh" athos@36: athos@36: using namespace marci; athos@36: athos@36: athos@36: int main (int, char*[]) athos@36: { athos@36: typedef graph_traits::node_iterator node_iterator; athos@36: typedef graph_traits::edge_iterator edge_iterator; athos@36: typedef graph_traits::each_node_iterator each_node_iterator; athos@36: typedef graph_traits::each_edge_iterator each_edge_iterator; athos@36: typedef graph_traits::out_edge_iterator out_edge_iterator; athos@36: typedef graph_traits::in_edge_iterator in_edge_iterator; athos@36: typedef graph_traits::sym_edge_iterator sym_edge_iterator; athos@36: athos@36: list_graph flow_test; athos@36: athos@36: athos@36: //Ahuja könyv példája athos@36: node_iterator s=flow_test.add_node(); athos@36: node_iterator v2=flow_test.add_node(); athos@36: node_iterator v3=flow_test.add_node(); athos@36: node_iterator v4=flow_test.add_node(); athos@36: node_iterator v5=flow_test.add_node(); athos@36: node_iterator t=flow_test.add_node(); athos@36: athos@36: node_property_vector node_name(flow_test); athos@36: node_name.put(s, "s"); athos@36: node_name.put(v2, "v2"); athos@36: node_name.put(v3, "v3"); athos@36: node_name.put(v4, "v4"); athos@36: node_name.put(v5, "v5"); athos@36: node_name.put(t, "t"); athos@36: athos@36: athos@36: edge_iterator s_v2=flow_test.add_edge(s, v2); athos@36: edge_iterator s_v3=flow_test.add_edge(s, v3); athos@36: athos@36: edge_iterator v2_v4=flow_test.add_edge(v2, v4); athos@36: edge_iterator v2_v5=flow_test.add_edge(v2, v5); athos@36: athos@36: edge_iterator v3_v5=flow_test.add_edge(v3, v5); athos@36: athos@36: edge_iterator v4_t=flow_test.add_edge(v4, t); athos@36: edge_iterator v5_t=flow_test.add_edge(v5, t); athos@36: athos@36: //Kis modositas athos@36: edge_iterator v2_s=flow_test.add_edge(v2, s); athos@36: athos@36: edge_property_vector cap(flow_test); athos@36: cap.put(s_v2, 10); athos@36: cap.put(s_v3, 10); athos@36: cap.put(v2_v4, 5); athos@36: cap.put(v2_v5, 8); athos@36: cap.put(v3_v5, 5); athos@36: cap.put(v4_t, 8); athos@36: cap.put(v5_t, 8); athos@36: athos@36: //Kis modositas athos@36: cap.put(v2_s, 100); athos@36: athos@36: //Kis modositas athos@36: //edge_iterator t_s=flow_test.add_edge(t, s); athos@36: //cap.put(t_s, 20); athos@36: athos@36: athos@36: /* athos@36: //Marci példája athos@36: node_iterator s=flow_test.add_node(); athos@36: node_iterator v1=flow_test.add_node(); athos@36: node_iterator v2=flow_test.add_node(); athos@36: node_iterator v3=flow_test.add_node(); athos@36: node_iterator v4=flow_test.add_node(); athos@36: node_iterator t=flow_test.add_node(); athos@36: athos@36: node_property_vector node_name(flow_test); athos@36: node_name.put(s, "s"); athos@36: node_name.put(v1, "v1"); athos@36: node_name.put(v2, "v2"); athos@36: node_name.put(v3, "v3"); athos@36: node_name.put(v4, "v4"); athos@36: node_name.put(t, "t"); athos@36: athos@36: edge_iterator s_v1=flow_test.add_edge(s, v1); athos@36: edge_iterator s_v2=flow_test.add_edge(s, v2); athos@36: edge_iterator v1_v2=flow_test.add_edge(v1, v2); athos@36: edge_iterator v2_v1=flow_test.add_edge(v2, v1); athos@36: edge_iterator v1_v3=flow_test.add_edge(v1, v3); athos@36: edge_iterator v3_v2=flow_test.add_edge(v3, v2); athos@36: edge_iterator v2_v4=flow_test.add_edge(v2, v4); athos@36: edge_iterator v4_v3=flow_test.add_edge(v4, v3); athos@36: edge_iterator v3_t=flow_test.add_edge(v3, t); athos@36: edge_iterator v4_t=flow_test.add_edge(v4, t); athos@36: athos@36: edge_property_vector cap(flow_test); athos@36: cap.put(s_v1, 16); athos@36: cap.put(s_v2, 13); athos@36: cap.put(v1_v2, 10); athos@36: cap.put(v2_v1, 4); athos@36: cap.put(v1_v3, 12); athos@36: cap.put(v3_v2, 9); athos@36: cap.put(v2_v4, 14); athos@36: cap.put(v4_v3, 7); athos@36: cap.put(v3_t, 20); athos@36: cap.put(v4_t, 4); athos@36: */ athos@36: /*Egyszerű példa athos@36: node_iterator s=flow_test.add_node(); athos@36: node_iterator v1=flow_test.add_node(); athos@36: node_iterator v2=flow_test.add_node(); athos@36: node_iterator t=flow_test.add_node(); athos@36: athos@36: node_property_vector node_name(flow_test); athos@36: node_name.put(s, "s"); athos@36: node_name.put(v1, "v1"); athos@36: node_name.put(v2, "v2"); athos@36: node_name.put(t, "t"); athos@36: athos@36: edge_iterator s_v1=flow_test.add_edge(s, v1); athos@36: edge_iterator v1_v2=flow_test.add_edge(v1, v2); athos@36: edge_iterator v2_t=flow_test.add_edge(v2, t); athos@36: athos@36: edge_property_vector cap(flow_test); athos@36: athos@36: cap.put(s_v1, 16); athos@36: cap.put(v1_v2, 10); athos@36: cap.put(v2_t, 4); athos@36: */ athos@36: athos@36: std::cout << "preflow-push algorithm test..." << std::endl; athos@36: std::cout << "on directed graph graph" << std::endl; //<< flow_test; athos@36: std::cout << "names and capacity values" << std::endl; athos@36: for(each_node_iterator i=flow_test.first_node(); i.valid(); ++i) { athos@36: std::cout << node_name.get(i) << ": "; athos@36: std::cout << "out edges: "; athos@36: for(out_edge_iterator j=flow_test.first_out_edge(i); j.valid(); ++j) athos@36: std::cout << node_name.get(flow_test.tail(j)) << "-"<< cap.get(j) << "->" << node_name.get(flow_test.head(j)) << " "; athos@36: std::cout << "in edges: "; athos@36: for(in_edge_iterator j=flow_test.first_in_edge(i); j.valid(); ++j) athos@36: std::cout << node_name.get(flow_test.tail(j)) << "-"<< cap.get(j) << "->" << node_name.get(flow_test.head(j)) << " "; athos@36: std::cout << std::endl; athos@36: } athos@36: athos@36: athos@36: //for(each_node_iterator i=flow_test.first_node(); i.valid(); ++i) { athos@36: // std::cout << i << " "; athos@36: //} athos@36: athos@36: preflow_push preflow_push_test(flow_test, s, t, cap); athos@36: cout << preflow_push_test.run()<