1 | #include <iostream> |
---|

2 | #include <lemon/list_graph.h> |
---|

3 | |
---|

4 | int main() |
---|

5 | { |
---|

6 | typedef lemon::ListGraph Graph; |
---|

7 | typedef Graph::EdgeIt EdgeIt; |
---|

8 | typedef Graph::Edge Edge; |
---|

9 | typedef Graph::NodeIt NodeIt; |
---|

10 | typedef Graph::Node Node; |
---|

11 | typedef Graph::EdgeMap<int> LengthMap; |
---|

12 | using lemon::INVALID; |
---|

13 | |
---|

14 | Graph g; |
---|

15 | |
---|

16 | Node s=g.addNode(); |
---|

17 | Node v2=g.addNode(); |
---|

18 | Node v3=g.addNode(); |
---|

19 | Node v4=g.addNode(); |
---|

20 | Node v5=g.addNode(); |
---|

21 | Node t=g.addNode(); |
---|

22 | |
---|

23 | Edge s_v2=g.addEdge(s, v2); |
---|

24 | Edge s_v3=g.addEdge(s, v3); |
---|

25 | Edge v2_v4=g.addEdge(v2, v4); |
---|

26 | Edge v2_v5=g.addEdge(v2, v5); |
---|

27 | Edge v3_v5=g.addEdge(v3, v5); |
---|

28 | Edge v4_t=g.addEdge(v4, t); |
---|

29 | Edge v5_t=g.addEdge(v5, t); |
---|

30 | |
---|

31 | LengthMap length(g); |
---|

32 | |
---|

33 | length.set(s_v2, 10); |
---|

34 | length.set(s_v3, 10); |
---|

35 | length.set(v2_v4, 5); |
---|

36 | length.set(v2_v5, 8); |
---|

37 | length.set(v3_v5, 5); |
---|

38 | length.set(v4_t, 8); |
---|

39 | length.set(v5_t, 8); |
---|

40 | |
---|

41 | std::cout << "Hello World!" << std::endl; |
---|

42 | std::cout << std::endl; |
---|

43 | std::cout << "This is library LEMON here! We have a graph!" << std::endl; |
---|

44 | std::cout << std::endl; |
---|

45 | |
---|

46 | std::cout << "Nodes:"; |
---|

47 | for (NodeIt i(g); i!=INVALID; ++i) |
---|

48 | std::cout << " " << g.id(i); |
---|

49 | std::cout << std::endl; |
---|

50 | |
---|

51 | std::cout << "Edges:"; |
---|

52 | for (EdgeIt i(g); i!=INVALID; ++i) |
---|

53 | std::cout << " (" << g.id(g.source(i)) << "," << g.id(g.target(i)) << ")"; |
---|

54 | std::cout << std::endl; |
---|

55 | std::cout << std::endl; |
---|

56 | |
---|

57 | std::cout << "There is a map on the edges (length)!" << std::endl; |
---|

58 | std::cout << std::endl; |
---|

59 | for (EdgeIt i(g); i!=INVALID; ++i) |
---|

60 | std::cout << "length(" << g.id(g.source(i)) << "," << g.id(g.target(i)) << ")="<<length[i]<<std::endl; |
---|

61 | |
---|

62 | std::cout << std::endl; |
---|

63 | |
---|

64 | } |
---|