[946] | 1 | // -*- c++ -*- |
---|

| 2 | |
---|

| 3 | #ifndef LEMON_EXTENDABLE_GRAPH_EXTENDER_H |
---|

| 4 | #define LEMON_EXTENDABLE_GRAPH_EXTENDER_H |
---|

| 5 | |
---|

| 6 | namespace lemon { |
---|

| 7 | |
---|

| 8 | template <typename _Base> |
---|

| 9 | class ExtendableGraphExtender : public _Base { |
---|

| 10 | public: |
---|

| 11 | |
---|

| 12 | typedef ExtendableGraphExtender Graph; |
---|

| 13 | typedef _Base Parent; |
---|

| 14 | |
---|

| 15 | typedef typename Parent::Node Node; |
---|

| 16 | typedef typename Parent::Edge Edge; |
---|

| 17 | |
---|

| 18 | Node addNode() { |
---|

| 19 | Node node = Parent::addNode(); |
---|

[980] | 20 | Parent::getObserverRegistry(Node()).add(node); |
---|

[946] | 21 | return node; |
---|

| 22 | } |
---|

| 23 | |
---|

| 24 | Edge addEdge(const Node& from, const Node& to) { |
---|

| 25 | Edge edge = Parent::addEdge(from, to); |
---|

[980] | 26 | Parent::getObserverRegistry(Edge()).add(edge); |
---|

[946] | 27 | return edge; |
---|

| 28 | } |
---|

| 29 | |
---|

| 30 | }; |
---|

| 31 | |
---|

[1022] | 32 | template <typename _Base> |
---|

| 33 | class ExtendableUndirGraphExtender : public _Base { |
---|

| 34 | public: |
---|

| 35 | |
---|

| 36 | typedef ExtendableUndirGraphExtender Graph; |
---|

| 37 | typedef _Base Parent; |
---|

| 38 | |
---|

| 39 | typedef typename Parent::Node Node; |
---|

| 40 | typedef typename Parent::Edge Edge; |
---|

| 41 | typedef typename Parent::UndirEdge UndirEdge; |
---|

| 42 | |
---|

| 43 | Node addNode() { |
---|

| 44 | Node node = Parent::addNode(); |
---|

| 45 | Parent::getObserverRegistry(Node()).add(node); |
---|

| 46 | return node; |
---|

| 47 | } |
---|

| 48 | |
---|

| 49 | UndirEdge addEdge(const Node& from, const Node& to) { |
---|

| 50 | UndirEdge uedge = Parent::addEdge(from, to); |
---|

| 51 | Parent::getObserverRegistry(UndirEdge()).add(uedge); |
---|

| 52 | |
---|

| 53 | Edge edge_forward(uedge, true); |
---|

| 54 | Edge edge_backward(uedge, false); |
---|

| 55 | Parent::getObserverRegistry(Edge()).add(edge_forward); |
---|

| 56 | Parent::getObserverRegistry(Edge()).add(edge_backward); |
---|

| 57 | |
---|

| 58 | return uedge; |
---|

| 59 | } |
---|

| 60 | |
---|

| 61 | }; |
---|

| 62 | |
---|

[946] | 63 | } |
---|

| 64 | |
---|

| 65 | #endif |
---|