author | alpar |
Fri, 16 Apr 2004 21:18:40 +0000 | |
changeset 342 | c98125b3f47c |
parent 315 | 7b97540cd743 |
child 383 | 0d5a628cb184 |
permissions | -rw-r--r-- |
marci@315 | 1 |
// -*- c++ -*- |
marci@315 | 2 |
//compile it with |
marci@315 | 3 |
//g++ -ansi -pedantic |
marci@315 | 4 |
//and with |
marci@315 | 5 |
//g++ |
marci@315 | 6 |
//I did with g++ ver 3.0.4, suse 8.0 |
marci@315 | 7 |
//If the template is removed from NodeMap, then it works well. |
marci@315 | 8 |
//athos@cs.elte.hu |
marci@315 | 9 |
//klao@cs.elte.hu |
marci@315 | 10 |
//marci@cs.elte.hu |
marci@315 | 11 |
|
marci@315 | 12 |
class ListGraph { |
marci@315 | 13 |
public: |
marci@315 | 14 |
ListGraph() { } |
marci@315 | 15 |
|
marci@315 | 16 |
template <typename T> class NodeMap { |
marci@315 | 17 |
const ListGraph& G; |
marci@315 | 18 |
public: |
marci@315 | 19 |
NodeMap(const ListGraph& _G) : G(_G) { } |
marci@315 | 20 |
}; |
marci@315 | 21 |
|
marci@315 | 22 |
}; |
marci@315 | 23 |
|
marci@315 | 24 |
template<typename Graph> class GraphWrapper { |
marci@315 | 25 |
protected: |
marci@315 | 26 |
Graph* graph; |
marci@315 | 27 |
public: |
marci@315 | 28 |
GraphWrapper(Graph& _graph) : graph(&_graph) { } |
marci@315 | 29 |
|
marci@315 | 30 |
template<typename T> class NodeMap : public Graph::NodeMap<T> { |
marci@315 | 31 |
public: |
marci@315 | 32 |
NodeMap(const GraphWrapper<Graph>& _G) : |
marci@315 | 33 |
Graph::NodeMap<T>(*(_G.graph)) { } |
marci@315 | 34 |
}; |
marci@315 | 35 |
}; |
marci@315 | 36 |
|
marci@315 | 37 |
template<typename Graph> |
marci@315 | 38 |
class ResGraphWrapper : public GraphWrapper<Graph> { |
marci@315 | 39 |
public: |
marci@315 | 40 |
ResGraphWrapper(Graph& _graph) : GraphWrapper<Graph>(_graph) { } |
marci@315 | 41 |
}; |
marci@315 | 42 |
|
marci@315 | 43 |
template <typename Graph> class MaxFlow { |
marci@315 | 44 |
const Graph* g; |
marci@315 | 45 |
typedef ResGraphWrapper<const Graph> ResGW; |
marci@315 | 46 |
public: |
marci@315 | 47 |
MaxFlow(const Graph& _g) : g(&_g) { } |
marci@315 | 48 |
void augmentOnShortestPath() { |
marci@315 | 49 |
ResGW res_graph(*g); |
marci@315 | 50 |
typename ResGW::NodeMap<int> pred(res_graph); |
marci@315 | 51 |
} |
marci@315 | 52 |
}; |
marci@315 | 53 |
|
marci@315 | 54 |
int main(int, char **) { |
marci@315 | 55 |
ListGraph G; |
marci@315 | 56 |
MaxFlow<ListGraph> max_flow_test(G); |
marci@315 | 57 |
max_flow_test.augmentOnShortestPath(); |
marci@315 | 58 |
return 0; |
marci@315 | 59 |
} |