marci@9: #include marci@9: #include marci@9: #include marci@9: marci@9: #include marci@9: #include marci@9: #include marci@9: #include marci@9: marci@9: using namespace marci; marci@9: marci@9: int main (int, char*[]) marci@9: { marci@19: typedef list_graph::node_iterator node_iterator; marci@19: typedef list_graph::edge_iterator edge_iterator; marci@19: typedef list_graph::each_node_iterator each_node_iterator; marci@19: typedef list_graph::each_edge_iterator each_edge_iterator; marci@19: typedef list_graph::out_edge_iterator out_edge_iterator; marci@19: typedef list_graph::in_edge_iterator in_edge_iterator; marci@19: typedef list_graph::sym_edge_iterator sym_edge_iterator; marci@9: list_graph G; marci@9: std::vector vector_of_node_iterators; marci@9: for(int i=0; i!=8; ++i) vector_of_node_iterators.push_back(G.add_node()); marci@9: for(int i=0; i!=8; ++i) marci@9: for(int j=0; j!=8; ++j) { marci@9: if ((ij is arc iff i" << G.id(G.head(j)) << ") "; marci@9: } marci@9: std::cout << std::endl; marci@12: marci@12: std::cout<< " "; marci@19: for(out_edge_iterator j=G.first_out_edge(i); j.valid(); ++j) { marci@12: std::cout << G.a_node(j) << "->" << G.b_node(j) << " "; } marci@12: std::cout<" << G.b_node(j) << " "; } marci@12: std::cout<" << G.b_node(j) << " "; } marci@12: std::cout< my_property_vector(G); marci@9: each_node_iterator v; marci@9: G.get_first(v); marci@9: my_property_vector.put(v, 42); marci@9: my_property_vector.put(++G.first_node(), 314); marci@9: my_property_vector.put(++++G.first_node(), 1956); marci@9: my_property_vector.put(vector_of_node_iterators[3], 1989); marci@9: my_property_vector.put(vector_of_node_iterators[4], 2003); marci@9: my_property_vector.put(vector_of_node_iterators[7], 1978); marci@9: std::cout << "some node property values..." << std::endl; marci@19: for(each_node_iterator i=G.first_node(); i.valid(); ++i) { marci@9: std::cout << my_property_vector.get(i) << std::endl; marci@9: } marci@9: int _i=1; marci@9: int _ii=1; marci@9: edge_property_vector my_edge_property(G); marci@19: for(each_edge_iterator i=G.first_edge(); i.valid(); ++i) { marci@9: my_edge_property.put(i, _i); marci@9: _i*=_ii; ++_ii; marci@9: } marci@9: marci@9: std::cout << "node and edge property values on the tails and heads of edges..." << std::endl; marci@19: for(each_edge_iterator j=G.first_edge(); j.valid(); ++j) { marci@9: std::cout << my_property_vector.get(G.tail(j)) << "--" << my_edge_property.get(j) << "-->" << my_property_vector.get(G.head(j)) << " "; marci@9: } marci@9: std::cout << std::endl; marci@9: marci@9: //std::cout << "the same for inedges of the nodes..." << std::endl; marci@9: //k=0; marci@19: //for(each_node_iterator i=G.first_node(); i.valid(); ++i) { marci@19: // for(in_edge_iterator j=G.first_in_edge(i); j.valid(); ++j) { marci@9: // std::cout << my_property_vector.get(G.tail(j)) << "-->" << my_property_vector.get(G.head(j)) << " "; marci@9: // } marci@9: // std::cout << std::endl; marci@9: //} marci@9: marci@9: std::cout << "bfs from the first node" << std::endl; marci@9: bfs bfs_test(G, G.first_node()); marci@9: bfs_test.run(); marci@9: std::cout << "reached: "; marci@19: for(each_node_iterator i=G.first_node(); i.valid(); ++i) { marci@9: std::cout << bfs_test.reached.get(i) << " "; marci@9: } marci@9: std::cout< node_name(flow_test); marci@9: node_name.put(s, "s"); marci@9: node_name.put(v1, "v1"); marci@9: node_name.put(v2, "v2"); marci@9: node_name.put(v3, "v3"); marci@9: node_name.put(v4, "v4"); marci@9: node_name.put(t, "t"); marci@9: marci@9: edge_iterator s_v1=flow_test.add_edge(s, v1); marci@9: edge_iterator s_v2=flow_test.add_edge(s, v2); marci@9: edge_iterator v1_v2=flow_test.add_edge(v1, v2); marci@9: edge_iterator v2_v1=flow_test.add_edge(v2, v1); marci@9: edge_iterator v1_v3=flow_test.add_edge(v1, v3); marci@9: edge_iterator v3_v2=flow_test.add_edge(v3, v2); marci@9: edge_iterator v2_v4=flow_test.add_edge(v2, v4); marci@9: edge_iterator v4_v3=flow_test.add_edge(v4, v3); marci@9: edge_iterator v3_t=flow_test.add_edge(v3, t); marci@9: edge_iterator v4_t=flow_test.add_edge(v4, t); marci@9: marci@9: edge_property_vector cap(flow_test); marci@9: marci@9: cap.put(s_v1, 16); marci@9: cap.put(s_v2, 13); marci@9: cap.put(v1_v2, 10); marci@9: cap.put(v2_v1, 4); marci@9: cap.put(v1_v3, 12); marci@9: cap.put(v3_v2, 9); marci@9: cap.put(v2_v4, 14); marci@9: cap.put(v4_v3, 7); marci@9: cap.put(v3_t, 20); marci@9: cap.put(v4_t, 4); marci@9: marci@9: std::cout << "on directed graph graph" << std::endl; //<< flow_test; marci@9: std::cout << "names and capacity values" << std::endl; marci@19: for(each_node_iterator i=flow_test.first_node(); i.valid(); ++i) { marci@9: std::cout << node_name.get(i) << ": "; marci@9: std::cout << "out edges: "; marci@19: for(out_edge_iterator j=flow_test.first_out_edge(i); j.valid(); ++j) marci@9: std::cout << node_name.get(flow_test.tail(j)) << "-"<< cap.get(j) << "->" << node_name.get(flow_test.head(j)) << " "; marci@9: std::cout << "in edges: "; marci@19: for(in_edge_iterator j=flow_test.first_in_edge(i); j.valid(); ++j) marci@9: std::cout << node_name.get(flow_test.tail(j)) << "-"<< cap.get(j) << "->" << node_name.get(flow_test.head(j)) << " "; marci@9: std::cout << std::endl; marci@9: } marci@9: marci@9: marci@19: //for(each_node_iterator i=flow_test.first_node(); i.valid(); ++i) { marci@9: // std::cout << i << " "; marci@9: //} marci@9: marci@9: max_flow_type max_flow_test(flow_test, s, t, cap); marci@9: max_flow_test.run(); marci@9: marci@9: return 0; marci@9: }