klao@946: // -*- c++ -*-
klao@946: 
klao@946: #ifndef LEMON_EXTENDABLE_GRAPH_EXTENDER_H
klao@946: #define LEMON_EXTENDABLE_GRAPH_EXTENDER_H
klao@946: 
klao@946: namespace lemon {
klao@946: 
klao@946:   template <typename _Base> 
klao@946:   class ExtendableGraphExtender : public _Base {
klao@946:   public:
klao@946: 
klao@946:     typedef ExtendableGraphExtender Graph;
klao@946:     typedef _Base Parent;
klao@946: 
klao@946:     typedef typename Parent::Node Node;
klao@946:     typedef typename Parent::Edge Edge;
klao@946: 
klao@946:     Node addNode() {
klao@946:       Node node = Parent::addNode();
deba@1039:       Parent::getNotifier(Node()).add(node);
klao@946:       return node;
klao@946:     }
klao@946:     
klao@946:     Edge addEdge(const Node& from, const Node& to) {
klao@946:       Edge edge = Parent::addEdge(from, to);
deba@1039:       Parent::getNotifier(Edge()).add(edge);
klao@946:       return edge;
klao@946:     }
klao@946: 
klao@946:   };
klao@946: 
klao@1022:   template <typename _Base> 
klao@1022:   class ExtendableUndirGraphExtender : public _Base {
klao@1022:   public:
klao@1022: 
klao@1022:     typedef ExtendableUndirGraphExtender Graph;
klao@1022:     typedef _Base Parent;
klao@1022: 
klao@1022:     typedef typename Parent::Node Node;
klao@1022:     typedef typename Parent::Edge Edge;
klao@1022:     typedef typename Parent::UndirEdge UndirEdge;
klao@1022: 
klao@1022:     Node addNode() {
klao@1022:       Node node = Parent::addNode();
deba@1039:       Parent::getNotifier(Node()).add(node);
klao@1022:       return node;
klao@1022:     }
klao@1022: 
klao@1022:     UndirEdge addEdge(const Node& from, const Node& to) {
klao@1022:       UndirEdge uedge = Parent::addEdge(from, to);
deba@1039:       Parent::getNotifier(UndirEdge()).add(uedge);
klao@1022: 
klao@1022:       Edge edge_forward(uedge, true);
klao@1022:       Edge edge_backward(uedge, false);
deba@1039:       Parent::getNotifier(Edge()).add(edge_forward);
deba@1039:       Parent::getNotifier(Edge()).add(edge_backward);
klao@1022: 
klao@1022:       return uedge;
klao@1022:     }
klao@1022: 
klao@1022:   };
klao@1022: 
klao@946: }
klao@946: 
klao@946: #endif