COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/work/athos/pf_demo.cc @ 686:fc8a3393e0d9

Last change on this file since 686:fc8a3393e0d9 was 331:f5461f8bc59b, checked in by athos, 21 years ago

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

File size: 2.1 KB
RevLine 
[36]1#include <iostream>
2#include <vector>
3#include <string>
4
[331]5#include "list_graph.h"
6//#include "marci_graph_traits.hh"
[77]7//#include "marci_property_vector.hh"
[36]8#include "preflow_push.hh"
9
[105]10using namespace hugo;
[36]11
12
13int main (int, char*[])
14{
15
[331]16  typedef ListGraph::Node Node;
17  typedef ListGraph::Edge Edge;
18
19  ListGraph graph;
[201]20
21  /*
[77]22  //Marci példája
[201]23
[77]24
[331]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();
[77]31 
32
[331]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);
[77]43
[331]44  ListGraph::EdgeMap<int> length(graph);
[77]45
[331]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);
[201]56  */
[77]57
58
[201]59  //Ahuja könyv példája
[77]60
[331]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();
[77]67
[331]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);
[36]75 
76  //Kis modositas
[331]77  //edge_iterator v2_s=graph.add_edge(v2, s);
[36]78
[331]79  ListGraph::EdgeMap<int> length(graph);
[201]80
[331]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);
[36]88
89  //Kis modositas
[331]90  //length.put(v2_s, 100);
[36]91
[77]92
93
[36]94  std::cout << "preflow-push algorithm test..." << std::endl;
[77]95
[36]96 
[331]97  preflow_push<ListGraph, int> preflow_push_test(graph, s, t, length);
[36]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.