// -*- c++ -*- #ifndef LEMON_EXTENDABLE_GRAPH_EXTENDER_H #define LEMON_EXTENDABLE_GRAPH_EXTENDER_H namespace lemon { template class ExtendableGraphExtender : public _Base { public: typedef ExtendableGraphExtender Graph; typedef _Base Parent; typedef typename Parent::Node Node; typedef typename Parent::Edge Edge; Node addNode() { Node node = Parent::addNode(); Parent::getNotifier(Node()).add(node); return node; } Edge addEdge(const Node& from, const Node& to) { Edge edge = Parent::addEdge(from, to); Parent::getNotifier(Edge()).add(edge); return edge; } }; template class ExtendableEdgeSetExtender : public _Base { public: typedef ExtendableEdgeSetExtender Graph; typedef _Base Parent; typedef typename Parent::Edge Edge; typedef typename Parent::Node Node; Edge addEdge(const Node& from, const Node& to) { Edge edge = Parent::addEdge(from, to); Parent::getNotifier(Edge()).add(edge); return edge; } }; template class ExtendableUGraphExtender : public _Base { public: typedef ExtendableUGraphExtender Graph; typedef _Base Parent; typedef typename Parent::Node Node; typedef typename Parent::Edge Edge; typedef typename Parent::UEdge UEdge; Node addNode() { Node node = Parent::addNode(); Parent::getNotifier(Node()).add(node); return node; } UEdge addEdge(const Node& from, const Node& to) { UEdge uedge = Parent::addEdge(from, to); Parent::getNotifier(UEdge()).add(uedge); std::vector edges; edges.push_back(Parent::direct(uedge, true)); edges.push_back(Parent::direct(uedge, false)); Parent::getNotifier(Edge()).add(edges); return uedge; } }; template class ExtendableUEdgeSetExtender : public _Base { public: typedef ExtendableUEdgeSetExtender Graph; typedef _Base Parent; typedef typename Parent::Node Node; typedef typename Parent::Edge Edge; typedef typename Parent::UEdge UEdge; UEdge addEdge(const Node& from, const Node& to) { UEdge uedge = Parent::addEdge(from, to); Parent::getNotifier(UEdge()).add(uedge); std::vector edges; edges.push_back(Parent::direct(uedge, true)); edges.push_back(Parent::direct(uedge, false)); Parent::getNotifier(Edge()).add(edges); return uedge; } }; template class ExtendableBpUGraphExtender : public _Base { public: typedef _Base Parent; typedef ExtendableBpUGraphExtender Graph; typedef typename Parent::Node Node; typedef typename Parent::BNode BNode; typedef typename Parent::ANode ANode; typedef typename Parent::Edge Edge; typedef typename Parent::UEdge UEdge; Node addANode() { Node node = Parent::addANode(); Parent::getNotifier(ANode()).add(node); Parent::getNotifier(Node()).add(node); return node; } Node addBNode() { Node node = Parent::addBNode(); Parent::getNotifier(BNode()).add(node); Parent::getNotifier(Node()).add(node); return node; } UEdge addEdge(const Node& source, const Node& target) { UEdge uedge = Parent::addEdge(source, target); Parent::getNotifier(UEdge()).add(uedge); std::vector edges; edges.push_back(Parent::direct(uedge, true)); edges.push_back(Parent::direct(uedge, false)); Parent::getNotifier(Edge()).add(edges); return uedge; } }; } #endif