Line | |
---|

1 | // -*- c++ -*- |
---|

2 | //compile it with |
---|

3 | //g++ -ansi -pedantic |
---|

4 | //and with |
---|

5 | //g++ |
---|

6 | //I did with g++ ver 3.0.4, suse 8.0 |
---|

7 | //If the template is removed from NodeMap, then it works well. |
---|

8 | //athos@cs.elte.hu |
---|

9 | //klao@cs.elte.hu |
---|

10 | //marci@cs.elte.hu |
---|

11 | |
---|

12 | class ListGraph { |
---|

13 | public: |
---|

14 | ListGraph() { } |
---|

15 | |
---|

16 | template <typename T> class NodeMap { |
---|

17 | const ListGraph& G; |
---|

18 | public: |
---|

19 | NodeMap(const ListGraph& _G) : G(_G) { } |
---|

20 | }; |
---|

21 | |
---|

22 | }; |
---|

23 | |
---|

24 | template<typename Graph> class GraphWrapper { |
---|

25 | protected: |
---|

26 | Graph* graph; |
---|

27 | public: |
---|

28 | GraphWrapper(Graph& _graph) : graph(&_graph) { } |
---|

29 | |
---|

30 | template<typename T> class NodeMap : public Graph::NodeMap<T> { |
---|

31 | public: |
---|

32 | NodeMap(const GraphWrapper<Graph>& _G) : |
---|

33 | Graph::NodeMap<T>(*(_G.graph)) { } |
---|

34 | }; |
---|

35 | }; |
---|

36 | |
---|

37 | template<typename Graph> |
---|

38 | class ResGraphWrapper : public GraphWrapper<Graph> { |
---|

39 | public: |
---|

40 | ResGraphWrapper(Graph& _graph) : GraphWrapper<Graph>(_graph) { } |
---|

41 | }; |
---|

42 | |
---|

43 | template <typename Graph> class MaxFlow { |
---|

44 | const Graph* g; |
---|

45 | typedef ResGraphWrapper<const Graph> ResGW; |
---|

46 | public: |
---|

47 | MaxFlow(const Graph& _g) : g(&_g) { } |
---|

48 | void augmentOnShortestPath() { |
---|

49 | ResGW res_graph(*g); |
---|

50 | typename ResGW::NodeMap<int> pred(res_graph); |
---|

51 | } |
---|

52 | }; |
---|

53 | |
---|

54 | int main(int, char **) { |
---|

55 | ListGraph G; |
---|

56 | MaxFlow<ListGraph> max_flow_test(G); |
---|

57 | max_flow_test.augmentOnShortestPath(); |
---|

58 | return 0; |
---|

59 | } |
---|

**Note:** See

TracBrowser
for help on using the repository browser.