Notebook style is provided. Without opportunity to close tabs. :-) But with all other necessary things (I think).
3 #ifndef LEMON_EXTENDABLE_GRAPH_EXTENDER_H
4 #define LEMON_EXTENDABLE_GRAPH_EXTENDER_H
8 template <typename _Base>
9 class ExtendableGraphExtender : public _Base {
12 typedef ExtendableGraphExtender Graph;
15 typedef typename Parent::Node Node;
16 typedef typename Parent::Edge Edge;
19 Node node = Parent::addNode();
20 Parent::getNotifier(Node()).add(node);
24 Edge addEdge(const Node& from, const Node& to) {
25 Edge edge = Parent::addEdge(from, to);
26 Parent::getNotifier(Edge()).add(edge);
32 template <typename _Base>
33 class ExtendableEdgeSetExtender : public _Base {
36 typedef ExtendableEdgeSetExtender Graph;
39 typedef typename Parent::Edge Edge;
40 typedef typename Parent::Node Node;
42 Edge addEdge(const Node& from, const Node& to) {
43 Edge edge = Parent::addEdge(from, to);
44 Parent::getNotifier(Edge()).add(edge);
50 template <typename _Base>
51 class ExtendableUndirGraphExtender : public _Base {
54 typedef ExtendableUndirGraphExtender Graph;
57 typedef typename Parent::Node Node;
58 typedef typename Parent::Edge Edge;
59 typedef typename Parent::UndirEdge UndirEdge;
62 Node node = Parent::addNode();
63 Parent::getNotifier(Node()).add(node);
67 UndirEdge addEdge(const Node& from, const Node& to) {
68 UndirEdge uedge = Parent::addEdge(from, to);
69 Parent::getNotifier(UndirEdge()).add(uedge);
71 std::vector<Edge> edges;
72 edges.push_back(Parent::direct(uedge, true));
73 edges.push_back(Parent::direct(uedge, false));
74 Parent::getNotifier(Edge()).add(edges);
81 template <typename _Base>
82 class ExtendableUndirEdgeSetExtender : public _Base {
85 typedef ExtendableUndirEdgeSetExtender Graph;
88 typedef typename Parent::Node Node;
89 typedef typename Parent::Edge Edge;
90 typedef typename Parent::UndirEdge UndirEdge;
92 UndirEdge addEdge(const Node& from, const Node& to) {
93 UndirEdge uedge = Parent::addEdge(from, to);
94 Parent::getNotifier(UndirEdge()).add(uedge);
96 std::vector<Edge> edges;
97 edges.push_back(Parent::direct(uedge, true));
98 edges.push_back(Parent::direct(uedge, false));
99 Parent::getNotifier(Edge()).add(edges);
107 template <typename _Base>
108 class ExtendableUndirBipartiteGraphExtender : public _Base {
111 typedef _Base Parent;
112 typedef ExtendableUndirBipartiteGraphExtender Graph;
114 typedef typename Parent::Node Node;
115 typedef typename Parent::LowerNode LowerNode;
116 typedef typename Parent::UpperNode UpperNode;
117 typedef typename Parent::Edge Edge;
118 typedef typename Parent::UndirEdge UndirEdge;
120 Node addUpperNode() {
121 Node node = Parent::addUpperNode();
122 Parent::getNotifier(UpperNode()).add(node);
123 Parent::getNotifier(Node()).add(node);
127 Node addLowerNode() {
128 Node node = Parent::addLowerNode();
129 Parent::getNotifier(LowerNode()).add(node);
130 Parent::getNotifier(Node()).add(node);
134 UndirEdge addEdge(const Node& source, const Node& target) {
135 UndirEdge undiredge = Parent::addEdge(source, target);
136 Parent::getNotifier(UndirEdge()).add(undiredge);
138 std::vector<Edge> edges;
139 edges.push_back(Parent::direct(undiredge, true));
140 edges.push_back(Parent::direct(undiredge, false));
141 Parent::getNotifier(Edge()).add(edges);