1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/lemon/bits/extendable_graph_extender.h Tue Apr 05 12:30:46 2005 +0000
1.3 @@ -0,0 +1,65 @@
1.4 +// -*- c++ -*-
1.5 +
1.6 +#ifndef LEMON_EXTENDABLE_GRAPH_EXTENDER_H
1.7 +#define LEMON_EXTENDABLE_GRAPH_EXTENDER_H
1.8 +
1.9 +namespace lemon {
1.10 +
1.11 + template <typename _Base>
1.12 + class ExtendableGraphExtender : public _Base {
1.13 + public:
1.14 +
1.15 + typedef ExtendableGraphExtender Graph;
1.16 + typedef _Base Parent;
1.17 +
1.18 + typedef typename Parent::Node Node;
1.19 + typedef typename Parent::Edge Edge;
1.20 +
1.21 + Node addNode() {
1.22 + Node node = Parent::addNode();
1.23 + Parent::getNotifier(Node()).add(node);
1.24 + return node;
1.25 + }
1.26 +
1.27 + Edge addEdge(const Node& from, const Node& to) {
1.28 + Edge edge = Parent::addEdge(from, to);
1.29 + Parent::getNotifier(Edge()).add(edge);
1.30 + return edge;
1.31 + }
1.32 +
1.33 + };
1.34 +
1.35 + template <typename _Base>
1.36 + class ExtendableUndirGraphExtender : public _Base {
1.37 + public:
1.38 +
1.39 + typedef ExtendableUndirGraphExtender Graph;
1.40 + typedef _Base Parent;
1.41 +
1.42 + typedef typename Parent::Node Node;
1.43 + typedef typename Parent::Edge Edge;
1.44 + typedef typename Parent::UndirEdge UndirEdge;
1.45 +
1.46 + Node addNode() {
1.47 + Node node = Parent::addNode();
1.48 + Parent::getNotifier(Node()).add(node);
1.49 + return node;
1.50 + }
1.51 +
1.52 + UndirEdge addEdge(const Node& from, const Node& to) {
1.53 + UndirEdge uedge = Parent::addEdge(from, to);
1.54 + Parent::getNotifier(UndirEdge()).add(uedge);
1.55 +
1.56 + Edge edge_forward(uedge, true);
1.57 + Edge edge_backward(uedge, false);
1.58 + Parent::getNotifier(Edge()).add(edge_forward);
1.59 + Parent::getNotifier(Edge()).add(edge_backward);
1.60 +
1.61 + return uedge;
1.62 + }
1.63 +
1.64 + };
1.65 +
1.66 +}
1.67 +
1.68 +#endif