lemon/bits/extendable_graph_extender.h
author alpar
Wed, 01 Feb 2006 12:55:38 +0000
changeset 1938 c339ade3ffc3
parent 1909 2d806130e700
child 1956 a055123339d5
permissions -rw-r--r--
Fix g++-3.4 executable's name
klao@946
     1
// -*- c++ -*-
klao@946
     2
klao@946
     3
#ifndef LEMON_EXTENDABLE_GRAPH_EXTENDER_H
klao@946
     4
#define LEMON_EXTENDABLE_GRAPH_EXTENDER_H
klao@946
     5
klao@946
     6
namespace lemon {
klao@946
     7
klao@946
     8
  template <typename _Base> 
klao@946
     9
  class ExtendableGraphExtender : public _Base {
klao@946
    10
  public:
klao@946
    11
klao@946
    12
    typedef ExtendableGraphExtender Graph;
klao@946
    13
    typedef _Base Parent;
klao@946
    14
klao@946
    15
    typedef typename Parent::Node Node;
klao@946
    16
    typedef typename Parent::Edge Edge;
klao@946
    17
klao@946
    18
    Node addNode() {
klao@946
    19
      Node node = Parent::addNode();
deba@1039
    20
      Parent::getNotifier(Node()).add(node);
klao@946
    21
      return node;
klao@946
    22
    }
klao@946
    23
    
klao@946
    24
    Edge addEdge(const Node& from, const Node& to) {
klao@946
    25
      Edge edge = Parent::addEdge(from, to);
deba@1039
    26
      Parent::getNotifier(Edge()).add(edge);
klao@946
    27
      return edge;
klao@946
    28
    }
klao@946
    29
klao@946
    30
  };
klao@946
    31
klao@1022
    32
  template <typename _Base> 
deba@1842
    33
  class ExtendableEdgeSetExtender : public _Base {
deba@1842
    34
  public:
deba@1842
    35
deba@1842
    36
    typedef ExtendableEdgeSetExtender Graph;
deba@1842
    37
    typedef _Base Parent;
deba@1842
    38
deba@1842
    39
    typedef typename Parent::Edge Edge;
deba@1842
    40
    typedef typename Parent::Node Node;
deba@1842
    41
deba@1842
    42
    Edge addEdge(const Node& from, const Node& to) {
deba@1842
    43
      Edge edge = Parent::addEdge(from, to);
deba@1842
    44
      Parent::getNotifier(Edge()).add(edge);
deba@1842
    45
      return edge;
deba@1842
    46
    }
deba@1842
    47
deba@1842
    48
  };
deba@1842
    49
deba@1842
    50
  template <typename _Base> 
klao@1909
    51
  class ExtendableUGraphExtender : public _Base {
klao@1022
    52
  public:
klao@1022
    53
klao@1909
    54
    typedef ExtendableUGraphExtender Graph;
klao@1022
    55
    typedef _Base Parent;
klao@1022
    56
klao@1022
    57
    typedef typename Parent::Node Node;
klao@1022
    58
    typedef typename Parent::Edge Edge;
klao@1909
    59
    typedef typename Parent::UEdge UEdge;
klao@1022
    60
klao@1022
    61
    Node addNode() {
klao@1022
    62
      Node node = Parent::addNode();
deba@1039
    63
      Parent::getNotifier(Node()).add(node);
klao@1022
    64
      return node;
klao@1022
    65
    }
klao@1022
    66
klao@1909
    67
    UEdge addEdge(const Node& from, const Node& to) {
klao@1909
    68
      UEdge uedge = Parent::addEdge(from, to);
klao@1909
    69
      Parent::getNotifier(UEdge()).add(uedge);
klao@1022
    70
deba@1414
    71
      std::vector<Edge> edges;
deba@1627
    72
      edges.push_back(Parent::direct(uedge, true));
deba@1627
    73
      edges.push_back(Parent::direct(uedge, false));
deba@1414
    74
      Parent::getNotifier(Edge()).add(edges);
klao@1022
    75
klao@1022
    76
      return uedge;
klao@1022
    77
    }
klao@1022
    78
klao@1022
    79
  };
klao@1022
    80
deba@1842
    81
  template <typename _Base> 
klao@1909
    82
  class ExtendableUEdgeSetExtender : public _Base {
deba@1842
    83
  public:
deba@1842
    84
klao@1909
    85
    typedef ExtendableUEdgeSetExtender Graph;
deba@1842
    86
    typedef _Base Parent;
deba@1842
    87
deba@1842
    88
    typedef typename Parent::Node Node;
deba@1842
    89
    typedef typename Parent::Edge Edge;
klao@1909
    90
    typedef typename Parent::UEdge UEdge;
deba@1842
    91
klao@1909
    92
    UEdge addEdge(const Node& from, const Node& to) {
klao@1909
    93
      UEdge uedge = Parent::addEdge(from, to);
klao@1909
    94
      Parent::getNotifier(UEdge()).add(uedge);
deba@1842
    95
deba@1842
    96
      std::vector<Edge> edges;
deba@1842
    97
      edges.push_back(Parent::direct(uedge, true));
deba@1842
    98
      edges.push_back(Parent::direct(uedge, false));
deba@1842
    99
      Parent::getNotifier(Edge()).add(edges);
deba@1842
   100
deba@1842
   101
      return uedge;
deba@1842
   102
    }
deba@1842
   103
deba@1842
   104
  };
deba@1842
   105
deba@1820
   106
deba@1820
   107
  template <typename _Base>
deba@1910
   108
  class ExtendableBpUGraphExtender : public _Base {
deba@1820
   109
  public:
deba@1820
   110
deba@1820
   111
    typedef _Base Parent;
deba@1910
   112
    typedef ExtendableBpUGraphExtender Graph;
deba@1820
   113
  
deba@1820
   114
    typedef typename Parent::Node Node;
deba@1910
   115
    typedef typename Parent::BNode BNode;
deba@1910
   116
    typedef typename Parent::ANode ANode;
deba@1820
   117
    typedef typename Parent::Edge Edge;
klao@1909
   118
    typedef typename Parent::UEdge UEdge;
deba@1820
   119
  
deba@1910
   120
    Node addANode() {
deba@1910
   121
      Node node = Parent::addANode();
deba@1910
   122
      Parent::getNotifier(ANode()).add(node);
deba@1820
   123
      Parent::getNotifier(Node()).add(node);
deba@1820
   124
      return node;
deba@1820
   125
    }
deba@1820
   126
deba@1910
   127
    Node addBNode() {
deba@1910
   128
      Node node = Parent::addBNode();
deba@1910
   129
      Parent::getNotifier(BNode()).add(node);
deba@1820
   130
      Parent::getNotifier(Node()).add(node);
deba@1820
   131
      return node;
deba@1820
   132
    }
deba@1820
   133
  
klao@1909
   134
    UEdge addEdge(const Node& source, const Node& target) {
klao@1909
   135
      UEdge uedge = Parent::addEdge(source, target);
klao@1909
   136
      Parent::getNotifier(UEdge()).add(uedge);
deba@1820
   137
    
deba@1820
   138
      std::vector<Edge> edges;
klao@1909
   139
      edges.push_back(Parent::direct(uedge, true));
klao@1909
   140
      edges.push_back(Parent::direct(uedge, false));
deba@1820
   141
      Parent::getNotifier(Edge()).add(edges);
deba@1820
   142
    
klao@1909
   143
      return uedge;
deba@1820
   144
    }
deba@1820
   145
deba@1820
   146
  };
deba@1820
   147
klao@946
   148
}
klao@946
   149
klao@946
   150
#endif