src/lemon/bits/extendable_graph_extender.h
author ladanyi
Thu, 05 May 2005 15:47:45 +0000
changeset 1406 15dac8ae3f8c
parent 1039 bd01c5a3f989
child 1414 01d9d6bc1284
permissions -rw-r--r--
fix 'make mrproper'
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> 
klao@1022
    33
  class ExtendableUndirGraphExtender : public _Base {
klao@1022
    34
  public:
klao@1022
    35
klao@1022
    36
    typedef ExtendableUndirGraphExtender Graph;
klao@1022
    37
    typedef _Base Parent;
klao@1022
    38
klao@1022
    39
    typedef typename Parent::Node Node;
klao@1022
    40
    typedef typename Parent::Edge Edge;
klao@1022
    41
    typedef typename Parent::UndirEdge UndirEdge;
klao@1022
    42
klao@1022
    43
    Node addNode() {
klao@1022
    44
      Node node = Parent::addNode();
deba@1039
    45
      Parent::getNotifier(Node()).add(node);
klao@1022
    46
      return node;
klao@1022
    47
    }
klao@1022
    48
klao@1022
    49
    UndirEdge addEdge(const Node& from, const Node& to) {
klao@1022
    50
      UndirEdge uedge = Parent::addEdge(from, to);
deba@1039
    51
      Parent::getNotifier(UndirEdge()).add(uedge);
klao@1022
    52
klao@1022
    53
      Edge edge_forward(uedge, true);
klao@1022
    54
      Edge edge_backward(uedge, false);
deba@1039
    55
      Parent::getNotifier(Edge()).add(edge_forward);
deba@1039
    56
      Parent::getNotifier(Edge()).add(edge_backward);
klao@1022
    57
klao@1022
    58
      return uedge;
klao@1022
    59
    }
klao@1022
    60
klao@1022
    61
  };
klao@1022
    62
klao@946
    63
}
klao@946
    64
klao@946
    65
#endif