# HG changeset patch # User marci # Date 1100788642 0 # Node ID a7d5fe18d8f994eb9e2d2342c88217c7ec67040f # Parent aa8c2f05b9ab1d85d63562d436c47dfbfd8440a5 MergeNodeGraphWrapper diff -r aa8c2f05b9ab -r a7d5fe18d8f9 src/work/marci/makefile --- a/src/work/marci/makefile Thu Nov 18 10:17:19 2004 +0000 +++ b/src/work/marci/makefile Thu Nov 18 14:37:22 2004 +0000 @@ -4,7 +4,7 @@ INCLUDEDIRS ?= -I../{jacint,marci,alpar,klao,akos,athos} -I../.. -I.. -I$(BOOSTROOT) LEDABINARIES = leda_graph_demo leda_bfs_dfs max_bipartite_matching_demo -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 +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 #BINARIES = preflow_bug #gw_vs_not preflow_demo_boost edmonds_karp_demo_boost preflow_demo_jacint preflow_demo_athos edmonds_karp_demo_alpar preflow_demo_leda diff -r aa8c2f05b9ab -r a7d5fe18d8f9 src/work/marci/merge_node_graph_wrapper.h --- a/src/work/marci/merge_node_graph_wrapper.h Thu Nov 18 10:17:19 2004 +0000 +++ b/src/work/marci/merge_node_graph_wrapper.h Thu Nov 18 14:37:22 2004 +0000 @@ -23,16 +23,28 @@ #include #include +#include +#include + namespace lemon { + template + class P1 : public GraphWrapperBase<_Graph1> { + }; + + template + class P2 : public GraphWrapperBase<_Graph2> { + }; + template class MergeNodeGraphWrapperBase : - public GraphWrapperBase<_Graph1>, public GraphWrapperBase<_Graph2> { + public P1<_Graph1>, public P2<_Graph2> { public: + void print() const { std::cout << "generic" << std::endl; } typedef _Graph1 Graph1; typedef _Graph2 Graph2; - typedef GraphWrapperBase<_Graph1> Parent1; - typedef GraphWrapperBase<_Graph2> Parent2; + typedef P1<_Graph1> Parent1; + typedef P2<_Graph2> Parent2; typedef typename Parent1::Node Graph1Node; typedef typename Parent2::Node Graph2Node; protected: @@ -149,6 +161,72 @@ }; + template + class MergeNodeGraphWrapperBase< + _Graph1, _Graph2, typename boost::enable_if< + boost::is_same >::type> : + public P1<_Graph1>, public P2<_Graph2> { + public : + void print() const { std::cout << "same" << std::endl; } + typedef _Graph1 Graph1; + typedef _Graph2 Graph2; + typedef P1<_Graph1> Parent1; + typedef P2<_Graph2> Parent2; + typedef typename Parent1::Node Graph1Node; + typedef typename Parent2::Node Graph2Node; + protected: + MergeNodeGraphWrapperBase() { } + public: + class Node { }; + class Edge { }; + void first() const; + void next() const; + }; + + template + class MergeNodeGraphWrapperBase< + _Graph1, _Graph2, typename boost::enable_if< + boost::is_base_and_derived >::type> : + public P1<_Graph1>, public P2<_Graph2> { + public : + void print() const { std::cout << "2. nagyobb" << std::endl; } + typedef _Graph1 Graph1; + typedef _Graph2 Graph2; + typedef P1<_Graph1> Parent1; + typedef P2<_Graph2> Parent2; + typedef typename Parent1::Node Graph1Node; + typedef typename Parent2::Node Graph2Node; + protected: + MergeNodeGraphWrapperBase() { } + public: + class Node { }; + class Edge { }; + void first() const; + void next() const; + }; + + template + class MergeNodeGraphWrapperBase< + _Graph1, _Graph2, typename boost::enable_if< + boost::is_base_and_derived >::type> : + public P1<_Graph1>, public P2<_Graph2> { + public : + void print() const { std::cout << "1. nagyobb" << std::endl; } + typedef _Graph1 Graph1; + typedef _Graph2 Graph2; + typedef P1<_Graph1> Parent1; + typedef P2<_Graph2> Parent2; + typedef typename Parent1::Node Graph1Node; + typedef typename Parent2::Node Graph2Node; + protected: + MergeNodeGraphWrapperBase() { } + public: + class Node { }; + class Edge { }; + void first() const; + void next() const; + }; + template class MergeNodeGraphWrapper : public diff -r aa8c2f05b9ab -r a7d5fe18d8f9 src/work/marci/merge_node_graph_wrapper_test.cc --- a/src/work/marci/merge_node_graph_wrapper_test.cc Thu Nov 18 10:17:19 2004 +0000 +++ b/src/work/marci/merge_node_graph_wrapper_test.cc Thu Nov 18 14:37:22 2004 +0000 @@ -9,6 +9,12 @@ using namespace lemon; +class Graph3 : ListGraph { +public: + class Node : public ListGraph::Node { }; + class Edge { }; +}; + int main() { typedef SmartGraph Graph1; typedef ListGraph Graph2; @@ -38,4 +44,37 @@ for (Graph2::NodeIt n(h); n!=INVALID; ++n) { cout << nm[n] << endl; } + + gw.print(); + + { +// typedef SmartGraph Graph1; + typedef ListGraph Graph1; + typedef ListGraph Graph2; + Graph1 g; + Graph2 h; + typedef MergeNodeGraphWrapper GW; + GW gw(g, h); + gw.print(); + } + { +// typedef SmartGraph Graph1; + typedef Graph3 Graph1; + typedef ListGraph Graph2; + Graph1 g; + Graph2 h; + typedef MergeNodeGraphWrapper GW; + GW gw(g, h); + gw.print(); + } + { +// typedef SmartGraph Graph1; + typedef ListGraph Graph1; + typedef Graph3 Graph2; + Graph1 g; + Graph2 h; + typedef MergeNodeGraphWrapper GW; + GW gw(g, h); + gw.print(); + } }