lemon/bits/extendable_graph_extender.h
author klao
Tue, 15 Nov 2005 20:51:06 +0000
changeset 1796 b6a58c8bea87
parent 1435 8e85e6bbefdf
child 1820 22099ef840d7
permissions -rw-r--r--
lp_skeleton: _getDual "implemented"
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
deba@1414
    53
      std::vector<Edge> edges;
deba@1627
    54
      edges.push_back(Parent::direct(uedge, true));
deba@1627
    55
      edges.push_back(Parent::direct(uedge, false));
deba@1414
    56
      Parent::getNotifier(Edge()).add(edges);
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