Line | |
---|

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

2 | #include <vector> |
---|

3 | |
---|

4 | #include <cmath> |
---|

5 | #include <cstdlib> |
---|

6 | |
---|

7 | #include <lemon/smart_graph.h> |
---|

8 | #include <lemon/graph_writer.h> |
---|

9 | |
---|

10 | using namespace lemon; |
---|

11 | using namespace std; |
---|

12 | |
---|

13 | int main(int argc, const char *argv[]) { |
---|

14 | typedef SmartGraph Graph; |
---|

15 | typedef Graph::Node Node; |
---|

16 | typedef Graph::Edge Edge; |
---|

17 | |
---|

18 | typedef Graph::EdgeMap<int> CapacityMap; |
---|

19 | |
---|

20 | const int n = argc > 1 ? atoi(argv[1]) : 1000; |
---|

21 | const int e = argc > 2 ? atoi(argv[2]) : (int)(n * log(n)); |
---|

22 | const int m = argc > 3 ? atoi(argv[3]) : 100; |
---|

23 | |
---|

24 | Graph graph; |
---|

25 | CapacityMap capacity(graph); |
---|

26 | vector<Node> nodes; |
---|

27 | |
---|

28 | for (int i = 0; i < n; ++i) { |
---|

29 | nodes.push_back(graph.addNode()); |
---|

30 | } |
---|

31 | for (int i = 0; i < e; ++i) { |
---|

32 | int s = (int)(n * (double)rand() / (RAND_MAX + 1.0)); |
---|

33 | int t = (int)(n * (double)rand() / (RAND_MAX + 1.0)); |
---|

34 | int c = (int)(m * (double)rand() / (RAND_MAX + 1.0)); |
---|

35 | Edge edge = graph.addEdge(nodes[s], nodes[t]); |
---|

36 | capacity[edge] = c; |
---|

37 | } |
---|

38 | int start = (int)(n * (double)rand() / (RAND_MAX + 1.0)); |
---|

39 | writeGraph(cout, graph, capacity, nodes[start]); |
---|

40 | return 0; |
---|

41 | } |
---|

**Note:** See

TracBrowser
for help on using the repository browser.