.
5 #include "marci_list_graph.hh"
6 #include "marci_graph_traits.hh"
7 #include "marci_property_vector.hh"
8 #include "preflow_push.hh"
10 using namespace marci;
13 int main (int, char*[])
15 typedef graph_traits<list_graph>::node_iterator node_iterator;
16 typedef graph_traits<list_graph>::edge_iterator edge_iterator;
17 typedef graph_traits<list_graph>::each_node_iterator each_node_iterator;
18 typedef graph_traits<list_graph>::each_edge_iterator each_edge_iterator;
19 typedef graph_traits<list_graph>::out_edge_iterator out_edge_iterator;
20 typedef graph_traits<list_graph>::in_edge_iterator in_edge_iterator;
21 typedef graph_traits<list_graph>::sym_edge_iterator sym_edge_iterator;
27 node_iterator s=flow_test.add_node();
28 node_iterator v2=flow_test.add_node();
29 node_iterator v3=flow_test.add_node();
30 node_iterator v4=flow_test.add_node();
31 node_iterator v5=flow_test.add_node();
32 node_iterator t=flow_test.add_node();
34 node_property_vector<list_graph, std::string> node_name(flow_test);
35 node_name.put(s, "s");
36 node_name.put(v2, "v2");
37 node_name.put(v3, "v3");
38 node_name.put(v4, "v4");
39 node_name.put(v5, "v5");
40 node_name.put(t, "t");
43 edge_iterator s_v2=flow_test.add_edge(s, v2);
44 edge_iterator s_v3=flow_test.add_edge(s, v3);
46 edge_iterator v2_v4=flow_test.add_edge(v2, v4);
47 edge_iterator v2_v5=flow_test.add_edge(v2, v5);
49 edge_iterator v3_v5=flow_test.add_edge(v3, v5);
51 edge_iterator v4_t=flow_test.add_edge(v4, t);
52 edge_iterator v5_t=flow_test.add_edge(v5, t);
55 edge_iterator v2_s=flow_test.add_edge(v2, s);
57 edge_property_vector<list_graph, int> cap(flow_test);
70 //edge_iterator t_s=flow_test.add_edge(t, s);
76 node_iterator s=flow_test.add_node();
77 node_iterator v1=flow_test.add_node();
78 node_iterator v2=flow_test.add_node();
79 node_iterator v3=flow_test.add_node();
80 node_iterator v4=flow_test.add_node();
81 node_iterator t=flow_test.add_node();
83 node_property_vector<list_graph, std::string> node_name(flow_test);
84 node_name.put(s, "s");
85 node_name.put(v1, "v1");
86 node_name.put(v2, "v2");
87 node_name.put(v3, "v3");
88 node_name.put(v4, "v4");
89 node_name.put(t, "t");
91 edge_iterator s_v1=flow_test.add_edge(s, v1);
92 edge_iterator s_v2=flow_test.add_edge(s, v2);
93 edge_iterator v1_v2=flow_test.add_edge(v1, v2);
94 edge_iterator v2_v1=flow_test.add_edge(v2, v1);
95 edge_iterator v1_v3=flow_test.add_edge(v1, v3);
96 edge_iterator v3_v2=flow_test.add_edge(v3, v2);
97 edge_iterator v2_v4=flow_test.add_edge(v2, v4);
98 edge_iterator v4_v3=flow_test.add_edge(v4, v3);
99 edge_iterator v3_t=flow_test.add_edge(v3, t);
100 edge_iterator v4_t=flow_test.add_edge(v4, t);
102 edge_property_vector<list_graph, int> cap(flow_test);
115 node_iterator s=flow_test.add_node();
116 node_iterator v1=flow_test.add_node();
117 node_iterator v2=flow_test.add_node();
118 node_iterator t=flow_test.add_node();
120 node_property_vector<list_graph, std::string> node_name(flow_test);
121 node_name.put(s, "s");
122 node_name.put(v1, "v1");
123 node_name.put(v2, "v2");
124 node_name.put(t, "t");
126 edge_iterator s_v1=flow_test.add_edge(s, v1);
127 edge_iterator v1_v2=flow_test.add_edge(v1, v2);
128 edge_iterator v2_t=flow_test.add_edge(v2, t);
130 edge_property_vector<list_graph, int> cap(flow_test);
137 std::cout << "preflow-push algorithm test..." << std::endl;
138 std::cout << "on directed graph graph" << std::endl; //<< flow_test;
139 std::cout << "names and capacity values" << std::endl;
140 for(each_node_iterator i=flow_test.first_node(); i.valid(); ++i) {
141 std::cout << node_name.get(i) << ": ";
142 std::cout << "out edges: ";
143 for(out_edge_iterator j=flow_test.first_out_edge(i); j.valid(); ++j)
144 std::cout << node_name.get(flow_test.tail(j)) << "-"<< cap.get(j) << "->" << node_name.get(flow_test.head(j)) << " ";
145 std::cout << "in edges: ";
146 for(in_edge_iterator j=flow_test.first_in_edge(i); j.valid(); ++j)
147 std::cout << node_name.get(flow_test.tail(j)) << "-"<< cap.get(j) << "->" << node_name.get(flow_test.head(j)) << " ";
148 std::cout << std::endl;
152 //for(each_node_iterator i=flow_test.first_node(); i.valid(); ++i) {
153 // std::cout << i << " ";
156 preflow_push<list_graph, int> preflow_push_test(flow_test, s, t, cap);
157 cout << preflow_push_test.run()<<endl;
160 //cout << preflow_push_test.run()<<endl;