Minimum cost flows of small values: algorithm from Andras Frank's lecture notes (approximately)
6 #include <list_graph.h>
7 #include <minlengthpaths.h>
16 typedef ListGraph::Node Node;
17 typedef ListGraph::Edge Edge;
25 NodeIt s=graph.addNode();
26 NodeIt v1=graph.addNode();
27 NodeIt v2=graph.addNode();
28 NodeIt v3=graph.addNode();
29 NodeIt v4=graph.addNode();
30 NodeIt t=graph.addNode();
33 EdgeIt s_v1=graph.addEdge(s, v1);
34 EdgeIt s_v2=graph.addEdge(s, v2);
35 EdgeIt v1_v2=graph.addEdge(v1, v2);
36 EdgeIt v2_v1=graph.addEdge(v2, v1);
37 EdgeIt v1_v3=graph.addEdge(v1, v3);
38 EdgeIt v3_v2=graph.addEdge(v3, v2);
39 EdgeIt v2_v4=graph.addEdge(v2, v4);
40 EdgeIt v4_v3=graph.addEdge(v4, v3);
41 EdgeIt v3_t=graph.addEdge(v3, t);
42 EdgeIt v4_t=graph.addEdge(v4, t);
44 ListGraph::EdgeMap<int> length(graph);
48 length.set(v1_v2, 10);
50 length.set(v1_v3, 12);
52 length.set(v2_v4, 14);
61 Node s=graph.addNode();
62 Node v2=graph.addNode();
63 Node v3=graph.addNode();
64 Node v4=graph.addNode();
65 Node v5=graph.addNode();
66 Node t=graph.addNode();
68 Edge s_v2=graph.addEdge(s, v2);
69 Edge s_v3=graph.addEdge(s, v3);
70 Edge v2_v4=graph.addEdge(v2, v4);
71 Edge v2_v5=graph.addEdge(v2, v5);
72 Edge v3_v5=graph.addEdge(v3, v5);
73 Edge v4_t=graph.addEdge(v4, t);
74 Edge v5_t=graph.addEdge(v5, t);
77 //edge_iterator v2_s=graph.add_edge(v2, s);
79 ListGraph::EdgeMap<int> length(graph);
90 //length.put(v2_s, 100);
96 NodeIt s=flow_test.add_node();
97 NodeIt v1=flow_test.add_node();
98 NodeIt v2=flow_test.add_node();
99 NodeIt t=flow_test.add_node();
101 node_property_vector<list_graph, std::string> node_name(flow_test);
102 node_name.put(s, "s");
103 node_name.put(v1, "v1");
104 node_name.put(v2, "v2");
105 node_name.put(t, "t");
107 edge_iterator s_v1=flow_test.add_edge(s, v1);
108 edge_iterator v1_v2=flow_test.add_edge(v1, v2);
109 edge_iterator v2_t=flow_test.add_edge(v2, t);
111 edge_property_vector<list_graph, int> length(flow_test);
113 length.put(s_v1, 16);
114 length.put(v1_v2, 10);
118 std::cout << "Suurballe algorithm test..." << std::endl;
122 MinLengthPaths<ListGraph, ListGraph::EdgeMap<int> >
123 surb_test(graph, length);
124 std::cout << surb_test.run(s,t,k) << std::endl;