[Lemon-commits] [lemon_svn] deba: r2256 - in hugo/trunk: lemon lemon/bits test

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:51:18 CET 2006


Author: deba
Date: Mon Oct 17 12:28:48 2005
New Revision: 2256

Modified:
   hugo/trunk/lemon/bits/alteration_notifier.h
   hugo/trunk/lemon/graph_utils.h
   hugo/trunk/lemon/list_graph.h
   hugo/trunk/lemon/smart_graph.h
   hugo/trunk/test/graph_utils_test.cc

Log:
Removing signal/commit Change from alteration notifier

It makes slower the change Target/Source functions
and used only by the In/Out DegMap



Modified: hugo/trunk/lemon/bits/alteration_notifier.h
==============================================================================
--- hugo/trunk/lemon/bits/alteration_notifier.h	(original)
+++ hugo/trunk/lemon/bits/alteration_notifier.h	Mon Oct 17 12:28:48 2005
@@ -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.

Modified: hugo/trunk/lemon/graph_utils.h
==============================================================================
--- hugo/trunk/lemon/graph_utils.h	(original)
+++ hugo/trunk/lemon/graph_utils.h	Mon Oct 17 12:28:48 2005
@@ -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 <typename _Graph>
@@ -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 <typename _Graph>

Modified: hugo/trunk/lemon/list_graph.h
==============================================================================
--- hugo/trunk/lemon/list_graph.h	(original)
+++ hugo/trunk/lemon/list_graph.h	Mon Oct 17 12:28:48 2005
@@ -338,9 +338,7 @@
     ///referencing the changed edge remain
     ///valid. However <tt>InEdge</tt>'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 <tt>OutEdge</tt>'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 <tt>OutEdge</tt>'s  and <tt>InEdge</tt>'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 <tt>InEdge</tt>'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 <tt>OutEdge</tt>'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.
     ///

Modified: hugo/trunk/lemon/smart_graph.h
==============================================================================
--- hugo/trunk/lemon/smart_graph.h	(original)
+++ hugo/trunk/lemon/smart_graph.h	Mon Oct 17 12:28:48 2005
@@ -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;
     }
   

Modified: hugo/trunk/test/graph_utils_test.cc
==============================================================================
--- hugo/trunk/test/graph_utils_test.cc	(original)
+++ hugo/trunk/test/graph_utils_test.cc	Mon Oct 17 12:28:48 2005
@@ -82,6 +82,7 @@
     const int edgeNum = 100;
     ListGraph graph;
     InDegMap<ListGraph> inDeg(graph);
+    OutDegMap<ListGraph> outDeg(graph);
     std::vector<ListGraph::Node> 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");
     }
   }



More information about the Lemon-commits mailing list