COIN-OR::LEMON - Graph Library

Changeset 1007:a7d5fe18d8f9 in lemon-0.x for src/work/marci


Ignore:
Timestamp:
11/18/04 15:37:22 (20 years ago)
Author:
marci
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1397
Message:

MergeNodeGraphWrapper?

Location:
src/work/marci
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/work/marci/makefile

    r944 r1007  
    55
    66LEDABINARIES = leda_graph_demo leda_bfs_dfs max_bipartite_matching_demo
    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
     7BINARIES = 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
    88#BINARIES = preflow_bug
    99#gw_vs_not preflow_demo_boost edmonds_karp_demo_boost preflow_demo_jacint preflow_demo_athos edmonds_karp_demo_alpar preflow_demo_leda
  • src/work/marci/merge_node_graph_wrapper.h

    r1002 r1007  
    2424#include <iostream>
    2525
     26#include <boost/type_traits.hpp>
     27#include <boost/utility/enable_if.hpp>
     28
    2629namespace lemon {
     30
     31  template <class _Graph1>
     32  class P1 : public GraphWrapperBase<_Graph1> {
     33  };
     34
     35  template <class _Graph2>
     36  class P2 : public GraphWrapperBase<_Graph2> {
     37  };
    2738
    2839  template <typename _Graph1, typename _Graph2, typename Enable=void>
    2940  class MergeNodeGraphWrapperBase :
    30     public GraphWrapperBase<_Graph1>, public GraphWrapperBase<_Graph2> {
    31   public:
    32     typedef _Graph1 Graph1;
    33     typedef _Graph2 Graph2;
    34     typedef GraphWrapperBase<_Graph1> Parent1;
    35     typedef GraphWrapperBase<_Graph2> Parent2;
     41    public P1<_Graph1>, public P2<_Graph2> {
     42  public:
     43    void print() const { std::cout << "generic" << std::endl; }
     44    typedef _Graph1 Graph1;
     45    typedef _Graph2 Graph2;
     46    typedef P1<_Graph1> Parent1;
     47    typedef P2<_Graph2> Parent2;
    3648    typedef typename Parent1::Node Graph1Node;
    3749    typedef typename Parent2::Node Graph2Node;
     
    150162  };
    151163
     164  template <typename _Graph1, typename _Graph2>
     165  class MergeNodeGraphWrapperBase<
     166    _Graph1, _Graph2, typename boost::enable_if<
     167    boost::is_same<typename _Graph1::Node, typename _Graph2::Node> >::type> :
     168    public P1<_Graph1>, public P2<_Graph2> {
     169  public :
     170    void print() const { std::cout << "same" << std::endl; }
     171    typedef _Graph1 Graph1;
     172    typedef _Graph2 Graph2;
     173    typedef P1<_Graph1> Parent1;
     174    typedef P2<_Graph2> Parent2;
     175    typedef typename Parent1::Node Graph1Node;
     176    typedef typename Parent2::Node Graph2Node;
     177  protected:
     178    MergeNodeGraphWrapperBase() { }
     179  public:
     180    class Node { };
     181    class Edge { };
     182    void first() const;
     183    void next() const;
     184  };
     185
     186  template <typename _Graph1, typename _Graph2>
     187  class MergeNodeGraphWrapperBase<
     188    _Graph1, _Graph2, typename boost::enable_if<
     189    boost::is_base_and_derived<typename _Graph1::Node, typename _Graph2::Node> >::type> :
     190    public P1<_Graph1>, public P2<_Graph2> {
     191  public :
     192    void print() const { std::cout << "2. nagyobb" << std::endl; }
     193    typedef _Graph1 Graph1;
     194    typedef _Graph2 Graph2;
     195    typedef P1<_Graph1> Parent1;
     196    typedef P2<_Graph2> Parent2;
     197    typedef typename Parent1::Node Graph1Node;
     198    typedef typename Parent2::Node Graph2Node;
     199  protected:
     200    MergeNodeGraphWrapperBase() { }
     201  public:
     202    class Node { };
     203    class Edge { };
     204    void first() const;
     205    void next() const;
     206  };
     207
     208  template <typename _Graph1, typename _Graph2>
     209  class MergeNodeGraphWrapperBase<
     210    _Graph1, _Graph2, typename boost::enable_if<
     211    boost::is_base_and_derived<typename _Graph2::Node, typename _Graph1::Node> >::type> :
     212    public P1<_Graph1>, public P2<_Graph2> {
     213  public :
     214    void print() const { std::cout << "1. nagyobb" << std::endl; }
     215    typedef _Graph1 Graph1;
     216    typedef _Graph2 Graph2;
     217    typedef P1<_Graph1> Parent1;
     218    typedef P2<_Graph2> Parent2;
     219    typedef typename Parent1::Node Graph1Node;
     220    typedef typename Parent2::Node Graph2Node;
     221  protected:
     222    MergeNodeGraphWrapperBase() { }
     223  public:
     224    class Node { };
     225    class Edge { };
     226    void first() const;
     227    void next() const;
     228  };
     229
    152230
    153231  template <typename _Graph1, typename _Graph2, typename Enable=void>
  • src/work/marci/merge_node_graph_wrapper_test.cc

    r921 r1007  
    99
    1010using namespace lemon;
     11
     12class Graph3 : ListGraph {
     13public:
     14  class Node : public ListGraph::Node { };
     15  class Edge { };
     16};
    1117
    1218int main() {
     
    3945    cout << nm[n] << endl;
    4046  }
     47
     48  gw.print();
     49
     50  {
     51//    typedef SmartGraph Graph1;
     52    typedef ListGraph Graph1;
     53    typedef ListGraph Graph2;
     54    Graph1 g;
     55    Graph2 h;
     56    typedef MergeNodeGraphWrapper<Graph1, Graph2> GW;
     57    GW gw(g, h);   
     58    gw.print();
     59  }
     60  {
     61//    typedef SmartGraph Graph1;
     62    typedef Graph3 Graph1;
     63    typedef ListGraph Graph2;
     64    Graph1 g;
     65    Graph2 h;
     66    typedef MergeNodeGraphWrapper<Graph1, Graph2> GW;
     67    GW gw(g, h);   
     68    gw.print();
     69  }
     70  {
     71//    typedef SmartGraph Graph1;
     72    typedef ListGraph Graph1;
     73    typedef Graph3 Graph2;
     74    Graph1 g;
     75    Graph2 h;
     76    typedef MergeNodeGraphWrapper<Graph1, Graph2> GW;
     77    GW gw(g, h);   
     78    gw.print();
     79  }
    4180}
Note: See TracChangeset for help on using the changeset viewer.