COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/work/athos/pf_demo.cc @ 554:2d27cbaa982d

Last change on this file since 554:2d27cbaa982d was 331:f5461f8bc59b, checked in by athos, 16 years ago

Elkezdtem atirni a preflow_push-t. Csinaltam egy backupot graph wrapper nelkul (without gw, azaz wogw)

File size: 2.1 KB
Line 
1#include <iostream>
2#include <vector>
3#include <string>
4
5#include "list_graph.h"
6//#include "marci_graph_traits.hh"
7//#include "marci_property_vector.hh"
8#include "preflow_push.hh"
9
10using namespace hugo;
11
12
13int main (int, char*[])
14{
15
16  typedef ListGraph::Node Node;
17  typedef ListGraph::Edge Edge;
18
19  ListGraph graph;
20
21  /*
22  //Marci példája
23
24
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();
31 
32
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);
43
44  ListGraph::EdgeMap<int> length(graph);
45
46  length.set(s_v1, 16);
47  length.set(s_v2, 13);
48  length.set(v1_v2, 10);
49  length.set(v2_v1, 4);
50  length.set(v1_v3, 12);
51  length.set(v3_v2, 9);
52  length.set(v2_v4, 14);
53  length.set(v4_v3, 7);
54  length.set(v3_t, 20);
55  length.set(v4_t, 4);
56  */
57
58
59  //Ahuja könyv példája
60
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();
67
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);
75 
76  //Kis modositas
77  //edge_iterator v2_s=graph.add_edge(v2, s);
78
79  ListGraph::EdgeMap<int> length(graph);
80
81  length.set(s_v2, 10);
82  length.set(s_v3, 10);
83  length.set(v2_v4, 5);
84  length.set(v2_v5, 8);
85  length.set(v3_v5, 5);
86  length.set(v4_t, 8);
87  length.set(v5_t, 8);
88
89  //Kis modositas
90  //length.put(v2_s, 100);
91
92
93
94  std::cout << "preflow-push algorithm test..." << std::endl;
95
96 
97  preflow_push<ListGraph, int> preflow_push_test(graph, s, t, length);
98  cout << preflow_push_test.run()<<endl;
99
100  //cap.put(v5_t, 9);
101  //cout << preflow_push_test.run()<<endl;
102
103  return 0;
104}
Note: See TracBrowser for help on using the repository browser.