# HG changeset patch # User deba # Date 1129544928 0 # Node ID 06f939455cb1824448dfc62f0fead41562e40a87 # Parent eb8bb91ba9e29a2a4a0f488eda81c7ebe8a9699a Removing signal/commit Change from alteration notifier It makes slower the change Target/Source functions and used only by the In/Out DegMap diff -r eb8bb91ba9e2 -r 06f939455cb1 lemon/bits/alteration_notifier.h --- a/lemon/bits/alteration_notifier.h Fri Oct 14 11:03:40 2005 +0000 +++ b/lemon/bits/alteration_notifier.h Mon Oct 17 10:28:48 2005 +0000 @@ -172,22 +172,6 @@ } } - /// \brief Signal a property change on the given item. - /// - /// Signal a property change on the given item. It should - /// be used always with the commitChange() function. - /// This function is called always the property change. - /// The commitChange() is called always after the change. - virtual void signalChange(const Item&) {} - - /// \brief Commit the property change on the given item. - /// - /// Commit the property change on the given item. It should - /// be used always with the signalChange() function. - /// This function is called always the property change. - /// The commitChange() is called always after the change. - virtual void commitChange(const Item&) {} - /// \brief The member function to notificate the observer about the /// container is built. /// @@ -324,32 +308,6 @@ (*it)->erase(items); } } - - /// \brief Signal a property change on the given item. - /// - /// Signal a property change on the given item. It should - /// be used always with the commitChange() function. - /// This function is called always the property change. - /// The commitChange() is called always after the change. - void signalChange(const Item& item) { - typename Container::iterator it; - for (it = container.begin(); it != container.end(); ++it) { - (*it)->signalChange(item); - } - } - - /// \brief Commit the property change on the given item. - /// - /// Commit the property change on the given item. It should - /// be used always with the signalChange() function. - /// This function is called always the property change. - /// The commitChange() is called always after the change. - void commitChange(const Item& item) { - typename Container::iterator it; - for (it = container.begin(); it != container.end(); ++it) { - (*it)->commitChange(item); - } - } /// \brief Notifies all the registered observers about the container is /// built. diff -r eb8bb91ba9e2 -r 06f939455cb1 lemon/graph_utils.h --- a/lemon/graph_utils.h Fri Oct 14 11:03:40 2005 +0000 +++ b/lemon/graph_utils.h Mon Oct 17 10:28:48 2005 +0000 @@ -1325,6 +1325,14 @@ /// in constant time. On the other hand, the values are updated automatically /// whenever the graph changes. /// + /// \warning Besides addNode() and addEdge(), a graph structure may provide + /// alternative ways to mogify the graph. The correct behavior of InDegMap + /// is not guarantied if these additional featureas are used. For example + /// the funstions \ref ListGraph::changeSource() "changeSource()", + /// \ref ListGraph::changeTarget() "changeTarget()" and + /// \ref ListGraph::reverseEdge() "reverseEdge()" + /// of \ref ListGraph will \e not update the degree values correctly. + /// /// \sa OutDegMap template @@ -1423,6 +1431,14 @@ /// in constant time. On the other hand, the values are updated automatically /// whenever the graph changes. /// + /// \warning Besides addNode() and addEdge(), a graph structure may provide + /// alternative ways to mogify the graph. The correct behavior of OutDegMap + /// is not guarantied if these additional featureas are used. For example + /// the funstions \ref ListGraph::changeSource() "changeSource()", + /// \ref ListGraph::changeTarget() "changeTarget()" and + /// \ref ListGraph::reverseEdge() "reverseEdge()" + /// of \ref ListGraph will \e not update the degree values correctly. + /// /// \sa InDegMap template diff -r eb8bb91ba9e2 -r 06f939455cb1 lemon/list_graph.h --- a/lemon/list_graph.h Fri Oct 14 11:03:40 2005 +0000 +++ b/lemon/list_graph.h Mon Oct 17 10:28:48 2005 +0000 @@ -338,9 +338,7 @@ ///referencing the changed edge remain ///valid. However InEdge's are invalidated. void changeTarget(Edge e, Node n) { - getNotifier(Edge()).signalChange(e); _changeTarget(e,n); - getNotifier(Edge()).commitChange(e); } /// Changes the source of \c e to \c n @@ -350,9 +348,7 @@ ///referencing the changed edge remain ///valid. However OutEdge's are invalidated. void changeSource(Edge e, Node n) { - getNotifier(Edge()).signalChange(e); _changeSource(e,n); - getNotifier(Edge()).commitChange(e); } /// Invert the direction of an edge. @@ -362,10 +358,8 @@ ///valid. However OutEdge's and InEdge's are invalidated. void reverseEdge(Edge e) { Node t=target(e); - getNotifier(Edge()).signalChange(e); _changeTarget(e,source(e)); _changeSource(e,t); - getNotifier(Edge()).commitChange(e); } ///Using this it possible to avoid the superfluous memory allocation. @@ -593,13 +587,7 @@ /// referencing the changed edge remain /// valid. However InEdge's are invalidated. void changeTarget(UndirEdge e, Node n) { - getNotifier(UndirEdge()).signalChange(e); - getNotifier(Edge()).signalChange(direct(e, true)); - getNotifier(Edge()).signalChange(direct(e, false)); _changeTarget(e,n); - getNotifier(UndirEdge()).commitChange(e); - getNotifier(Edge()).commitChange(direct(e, true)); - getNotifier(Edge()).commitChange(direct(e, false)); } /// Changes the source of \c e to \c n /// @@ -609,13 +597,7 @@ ///referencing the changed edge remain ///valid. However OutEdge's are invalidated. void changeSource(UndirEdge e, Node n) { - getNotifier(UndirEdge()).signalChange(e); - getNotifier(Edge()).signalChange(direct(e, true)); - getNotifier(Edge()).signalChange(direct(e, false)); _changeSource(e,n); - getNotifier(UndirEdge()).commitChange(e); - getNotifier(Edge()).commitChange(direct(e, true)); - getNotifier(Edge()).commitChange(direct(e, false)); } /// \brief Contract two nodes. /// diff -r eb8bb91ba9e2 -r 06f939455cb1 lemon/smart_graph.h --- a/lemon/smart_graph.h Fri Oct 14 11:03:40 2005 +0000 +++ b/lemon/smart_graph.h Mon Oct 17 10:28:48 2005 +0000 @@ -315,13 +315,7 @@ ///\todo It could be implemented in a bit faster way. Node split(Node n, bool connect = true) { - for (OutEdgeIt it(*this, n); it != INVALID; ++it) { - getNotifier(Edge()).signalChange(it); - } Node b = _split(n,connect); - for (OutEdgeIt it(*this, b); it != INVALID; ++it) { - getNotifier(Edge()).commitChange(it); - } return b; } diff -r eb8bb91ba9e2 -r 06f939455cb1 test/graph_utils_test.cc --- a/test/graph_utils_test.cc Fri Oct 14 11:03:40 2005 +0000 +++ b/test/graph_utils_test.cc Mon Oct 17 10:28:48 2005 +0000 @@ -82,6 +82,7 @@ const int edgeNum = 100; ListGraph graph; InDegMap inDeg(graph); + OutDegMap outDeg(graph); std::vector nodes(nodeNum); for (int i = 0; i < nodeNum; ++i) { nodes[i] = graph.addNode(); @@ -95,25 +96,8 @@ check(inDeg[nodes[i]] == countInEdges(graph, nodes[i]), "Wrong in degree map"); } - for (int i = 0; i < edgeNum; ++i) { - graph.changeTarget(edges[i], nodes[urandom(nodeNum)]); - } for (int i = 0; i < nodeNum; ++i) { - check(inDeg[nodes[i]] == countInEdges(graph, nodes[i]), - "Wrong in degree map"); - } - for (int i = 0; i < edgeNum; ++i) { - graph.changeSource(edges[i], nodes[urandom(nodeNum)]); - } - for (int i = 0; i < nodeNum; ++i) { - check(inDeg[nodes[i]] == countInEdges(graph, nodes[i]), - "Wrong in degree map"); - } - for (int i = 0; i < edgeNum; ++i) { - graph.reverseEdge(edges[i]); - } - for (int i = 0; i < nodeNum; ++i) { - check(inDeg[nodes[i]] == countInEdges(graph, nodes[i]), + check(outDeg[nodes[i]] == countOutEdges(graph, nodes[i]), "Wrong in degree map"); } }