1.1 --- a/src/work/marci/makefile Thu Nov 18 10:17:19 2004 +0000
1.2 +++ b/src/work/marci/makefile Thu Nov 18 14:37:22 2004 +0000
1.3 @@ -4,7 +4,7 @@
1.4 INCLUDEDIRS ?= -I../{jacint,marci,alpar,klao,akos,athos} -I../.. -I.. -I$(BOOSTROOT)
1.5
1.6 LEDABINARIES = leda_graph_demo leda_bfs_dfs max_bipartite_matching_demo
1.7 -BINARIES = bfsit_vs_byhand max_flow_demo bfs_mm_test#merge_node_graph_wrapper_test sub_graph_wrapper_demo.cc graph_wrapper_time iterator_bfs_demo macro_test lg_vs_sg_vs_sg bipartite_graph_wrapper_test bipartite_matching_demo top_sort_test max_flow_1 proba7 proba10
1.8 +BINARIES = merge_node_graph_wrapper_test# bfsit_vs_byhand max_flow_demo bfs_mm_test# sub_graph_wrapper_demo.cc graph_wrapper_time iterator_bfs_demo macro_test lg_vs_sg_vs_sg bipartite_graph_wrapper_test bipartite_matching_demo top_sort_test max_flow_1 proba7 proba10
1.9 #BINARIES = preflow_bug
1.10 #gw_vs_not preflow_demo_boost edmonds_karp_demo_boost preflow_demo_jacint preflow_demo_athos edmonds_karp_demo_alpar preflow_demo_leda
1.11
2.1 --- a/src/work/marci/merge_node_graph_wrapper.h Thu Nov 18 10:17:19 2004 +0000
2.2 +++ b/src/work/marci/merge_node_graph_wrapper.h Thu Nov 18 14:37:22 2004 +0000
2.3 @@ -23,16 +23,28 @@
2.4 #include <lemon/graph_wrapper.h>
2.5 #include <iostream>
2.6
2.7 +#include <boost/type_traits.hpp>
2.8 +#include <boost/utility/enable_if.hpp>
2.9 +
2.10 namespace lemon {
2.11
2.12 + template <class _Graph1>
2.13 + class P1 : public GraphWrapperBase<_Graph1> {
2.14 + };
2.15 +
2.16 + template <class _Graph2>
2.17 + class P2 : public GraphWrapperBase<_Graph2> {
2.18 + };
2.19 +
2.20 template <typename _Graph1, typename _Graph2, typename Enable=void>
2.21 class MergeNodeGraphWrapperBase :
2.22 - public GraphWrapperBase<_Graph1>, public GraphWrapperBase<_Graph2> {
2.23 + public P1<_Graph1>, public P2<_Graph2> {
2.24 public:
2.25 + void print() const { std::cout << "generic" << std::endl; }
2.26 typedef _Graph1 Graph1;
2.27 typedef _Graph2 Graph2;
2.28 - typedef GraphWrapperBase<_Graph1> Parent1;
2.29 - typedef GraphWrapperBase<_Graph2> Parent2;
2.30 + typedef P1<_Graph1> Parent1;
2.31 + typedef P2<_Graph2> Parent2;
2.32 typedef typename Parent1::Node Graph1Node;
2.33 typedef typename Parent2::Node Graph2Node;
2.34 protected:
2.35 @@ -149,6 +161,72 @@
2.36
2.37 };
2.38
2.39 + template <typename _Graph1, typename _Graph2>
2.40 + class MergeNodeGraphWrapperBase<
2.41 + _Graph1, _Graph2, typename boost::enable_if<
2.42 + boost::is_same<typename _Graph1::Node, typename _Graph2::Node> >::type> :
2.43 + public P1<_Graph1>, public P2<_Graph2> {
2.44 + public :
2.45 + void print() const { std::cout << "same" << std::endl; }
2.46 + typedef _Graph1 Graph1;
2.47 + typedef _Graph2 Graph2;
2.48 + typedef P1<_Graph1> Parent1;
2.49 + typedef P2<_Graph2> Parent2;
2.50 + typedef typename Parent1::Node Graph1Node;
2.51 + typedef typename Parent2::Node Graph2Node;
2.52 + protected:
2.53 + MergeNodeGraphWrapperBase() { }
2.54 + public:
2.55 + class Node { };
2.56 + class Edge { };
2.57 + void first() const;
2.58 + void next() const;
2.59 + };
2.60 +
2.61 + template <typename _Graph1, typename _Graph2>
2.62 + class MergeNodeGraphWrapperBase<
2.63 + _Graph1, _Graph2, typename boost::enable_if<
2.64 + boost::is_base_and_derived<typename _Graph1::Node, typename _Graph2::Node> >::type> :
2.65 + public P1<_Graph1>, public P2<_Graph2> {
2.66 + public :
2.67 + void print() const { std::cout << "2. nagyobb" << std::endl; }
2.68 + typedef _Graph1 Graph1;
2.69 + typedef _Graph2 Graph2;
2.70 + typedef P1<_Graph1> Parent1;
2.71 + typedef P2<_Graph2> Parent2;
2.72 + typedef typename Parent1::Node Graph1Node;
2.73 + typedef typename Parent2::Node Graph2Node;
2.74 + protected:
2.75 + MergeNodeGraphWrapperBase() { }
2.76 + public:
2.77 + class Node { };
2.78 + class Edge { };
2.79 + void first() const;
2.80 + void next() const;
2.81 + };
2.82 +
2.83 + template <typename _Graph1, typename _Graph2>
2.84 + class MergeNodeGraphWrapperBase<
2.85 + _Graph1, _Graph2, typename boost::enable_if<
2.86 + boost::is_base_and_derived<typename _Graph2::Node, typename _Graph1::Node> >::type> :
2.87 + public P1<_Graph1>, public P2<_Graph2> {
2.88 + public :
2.89 + void print() const { std::cout << "1. nagyobb" << std::endl; }
2.90 + typedef _Graph1 Graph1;
2.91 + typedef _Graph2 Graph2;
2.92 + typedef P1<_Graph1> Parent1;
2.93 + typedef P2<_Graph2> Parent2;
2.94 + typedef typename Parent1::Node Graph1Node;
2.95 + typedef typename Parent2::Node Graph2Node;
2.96 + protected:
2.97 + MergeNodeGraphWrapperBase() { }
2.98 + public:
2.99 + class Node { };
2.100 + class Edge { };
2.101 + void first() const;
2.102 + void next() const;
2.103 + };
2.104 +
2.105
2.106 template <typename _Graph1, typename _Graph2, typename Enable=void>
2.107 class MergeNodeGraphWrapper : public
3.1 --- a/src/work/marci/merge_node_graph_wrapper_test.cc Thu Nov 18 10:17:19 2004 +0000
3.2 +++ b/src/work/marci/merge_node_graph_wrapper_test.cc Thu Nov 18 14:37:22 2004 +0000
3.3 @@ -9,6 +9,12 @@
3.4
3.5 using namespace lemon;
3.6
3.7 +class Graph3 : ListGraph {
3.8 +public:
3.9 + class Node : public ListGraph::Node { };
3.10 + class Edge { };
3.11 +};
3.12 +
3.13 int main() {
3.14 typedef SmartGraph Graph1;
3.15 typedef ListGraph Graph2;
3.16 @@ -38,4 +44,37 @@
3.17 for (Graph2::NodeIt n(h); n!=INVALID; ++n) {
3.18 cout << nm[n] << endl;
3.19 }
3.20 +
3.21 + gw.print();
3.22 +
3.23 + {
3.24 +// typedef SmartGraph Graph1;
3.25 + typedef ListGraph Graph1;
3.26 + typedef ListGraph Graph2;
3.27 + Graph1 g;
3.28 + Graph2 h;
3.29 + typedef MergeNodeGraphWrapper<Graph1, Graph2> GW;
3.30 + GW gw(g, h);
3.31 + gw.print();
3.32 + }
3.33 + {
3.34 +// typedef SmartGraph Graph1;
3.35 + typedef Graph3 Graph1;
3.36 + typedef ListGraph Graph2;
3.37 + Graph1 g;
3.38 + Graph2 h;
3.39 + typedef MergeNodeGraphWrapper<Graph1, Graph2> GW;
3.40 + GW gw(g, h);
3.41 + gw.print();
3.42 + }
3.43 + {
3.44 +// typedef SmartGraph Graph1;
3.45 + typedef ListGraph Graph1;
3.46 + typedef Graph3 Graph2;
3.47 + Graph1 g;
3.48 + Graph2 h;
3.49 + typedef MergeNodeGraphWrapper<Graph1, Graph2> GW;
3.50 + GW gw(g, h);
3.51 + gw.print();
3.52 + }
3.53 }