klao@1520
|
1 |
#include <iostream>
|
klao@1520
|
2 |
#include <lemon/list_graph.h>
|
klao@1520
|
3 |
|
klao@1520
|
4 |
int main()
|
klao@1520
|
5 |
{
|
klao@1520
|
6 |
typedef lemon::ListGraph Graph;
|
klao@1520
|
7 |
typedef Graph::EdgeIt EdgeIt;
|
athos@1530
|
8 |
typedef Graph::Edge Edge;
|
klao@1520
|
9 |
typedef Graph::NodeIt NodeIt;
|
athos@1530
|
10 |
typedef Graph::Node Node;
|
athos@1530
|
11 |
typedef Graph::EdgeMap<int> LengthMap;
|
klao@1520
|
12 |
using lemon::INVALID;
|
klao@1520
|
13 |
|
klao@1520
|
14 |
Graph g;
|
klao@1520
|
15 |
|
athos@1530
|
16 |
Node s=g.addNode();
|
athos@1530
|
17 |
Node v2=g.addNode();
|
athos@1530
|
18 |
Node v3=g.addNode();
|
athos@1530
|
19 |
Node v4=g.addNode();
|
athos@1530
|
20 |
Node v5=g.addNode();
|
athos@1530
|
21 |
Node t=g.addNode();
|
athos@1530
|
22 |
|
athos@1530
|
23 |
Edge s_v2=g.addEdge(s, v2);
|
athos@1530
|
24 |
Edge s_v3=g.addEdge(s, v3);
|
athos@1530
|
25 |
Edge v2_v4=g.addEdge(v2, v4);
|
athos@1530
|
26 |
Edge v2_v5=g.addEdge(v2, v5);
|
athos@1530
|
27 |
Edge v3_v5=g.addEdge(v3, v5);
|
athos@1530
|
28 |
Edge v4_t=g.addEdge(v4, t);
|
athos@1530
|
29 |
Edge v5_t=g.addEdge(v5, t);
|
klao@1520
|
30 |
|
athos@1530
|
31 |
LengthMap length(g);
|
athos@1530
|
32 |
|
athos@1530
|
33 |
length.set(s_v2, 10);
|
athos@1530
|
34 |
length.set(s_v3, 10);
|
athos@1530
|
35 |
length.set(v2_v4, 5);
|
athos@1530
|
36 |
length.set(v2_v5, 8);
|
athos@1530
|
37 |
length.set(v3_v5, 5);
|
athos@1530
|
38 |
length.set(v4_t, 8);
|
athos@1530
|
39 |
length.set(v5_t, 8);
|
klao@1520
|
40 |
|
athos@1526
|
41 |
std::cout << "Hello World!" << std::endl;
|
athos@1526
|
42 |
std::cout << std::endl;
|
athos@1526
|
43 |
std::cout << "This is library LEMON here! We have a graph!" << std::endl;
|
athos@1526
|
44 |
std::cout << std::endl;
|
athos@1526
|
45 |
|
klao@1520
|
46 |
std::cout << "Nodes:";
|
klao@1520
|
47 |
for (NodeIt i(g); i!=INVALID; ++i)
|
klao@1520
|
48 |
std::cout << " " << g.id(i);
|
klao@1520
|
49 |
std::cout << std::endl;
|
klao@1520
|
50 |
|
klao@1520
|
51 |
std::cout << "Edges:";
|
klao@1520
|
52 |
for (EdgeIt i(g); i!=INVALID; ++i)
|
klao@1520
|
53 |
std::cout << " (" << g.id(g.source(i)) << "," << g.id(g.target(i)) << ")";
|
klao@1520
|
54 |
std::cout << std::endl;
|
athos@1530
|
55 |
std::cout << std::endl;
|
athos@1530
|
56 |
|
athos@1530
|
57 |
std::cout << "There is a map on the edges (length)!" << std::endl;
|
athos@1530
|
58 |
std::cout << std::endl;
|
athos@1530
|
59 |
for (EdgeIt i(g); i!=INVALID; ++i)
|
athos@1530
|
60 |
std::cout << "length(" << g.id(g.source(i)) << "," << g.id(g.target(i)) << ")="<<length[i]<<std::endl;
|
athos@1530
|
61 |
|
athos@1530
|
62 |
std::cout << std::endl;
|
athos@1530
|
63 |
|
klao@1520
|
64 |
}
|