commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1204190 - in /commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit: BaseGraphVisitHandler.java GraphVisitHandler.java Visit.java VisitGraphBuilder.java
Date Sun, 20 Nov 2011 17:06:32 GMT
Author: simonetripodi
Date: Sun Nov 20 17:06:32 2011
New Revision: 1204190

URL: http://svn.apache.org/viewvc?rev=1204190&view=rev
Log:
changed handler method signature, providing more informations, to reduce load that clients
have to perform on the Graph

Modified:
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/BaseGraphVisitHandler.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/GraphVisitHandler.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/Visit.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/VisitGraphBuilder.java

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/BaseGraphVisitHandler.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/BaseGraphVisitHandler.java?rev=1204190&r1=1204189&r2=1204190&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/BaseGraphVisitHandler.java
(original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/BaseGraphVisitHandler.java
Sun Nov 20 17:06:32 2011
@@ -52,7 +52,7 @@ public class BaseGraphVisitHandler<V ext
     /**
      * {@inheritDoc}
      */
-    public void discoverEdge( E edge )
+    public void discoverEdge( V head, E edge, V tail )
     {
         // do nothing
     }
@@ -60,7 +60,7 @@ public class BaseGraphVisitHandler<V ext
     /**
      * {@inheritDoc}
      */
-    public void finishEdge( E edge )
+    public void finishEdge( V head, E edge, V tail )
     {
         // do nothing
     }

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/GraphVisitHandler.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/GraphVisitHandler.java?rev=1204190&r1=1204189&r2=1204190&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/GraphVisitHandler.java
(original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/GraphVisitHandler.java
Sun Nov 20 17:06:32 2011
@@ -42,12 +42,12 @@ public interface GraphVisitHandler<V ext
     /**
      * Description of the Method
      */
-    void discoverEdge( E edge );
+    void discoverEdge( V head, E edge, V tail );
 
     /**
      * Description of the Method
      */
-    void finishEdge( E edge );
+    void finishEdge( V head, E edge, V tail );
 
     /**
      * Description of the Method

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/Visit.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/Visit.java?rev=1204190&r1=1204189&r2=1204190&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/Visit.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/Visit.java Sun
Nov 20 17:06:32 2011
@@ -99,11 +99,11 @@ public final class Visit
                 {
                     E e = graph.getEdge( v, w );
 
-                    handler.discoverEdge( e );
+                    handler.discoverEdge( v, e, w );
 
                     vertexQueue.offer( w );
 
-                    handler.finishEdge( e );
+                    handler.finishEdge( v, e, w );
                 }
             }
 
@@ -176,11 +176,11 @@ public final class Visit
                 {
                     E e = graph.getEdge( v, w );
 
-                    handler.discoverEdge( e );
+                    handler.discoverEdge( v, e, w );
 
                     vertexStack.push( w );
 
-                    handler.finishEdge( e );
+                    handler.finishEdge( v, e, w );
                 }
             }
 

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/VisitGraphBuilder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/VisitGraphBuilder.java?rev=1204190&r1=1204189&r2=1204190&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/VisitGraphBuilder.java
(original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/VisitGraphBuilder.java
Sun Nov 20 17:06:32 2011
@@ -23,7 +23,6 @@ import org.apache.commons.graph.Directed
 import org.apache.commons.graph.Edge;
 import org.apache.commons.graph.Graph;
 import org.apache.commons.graph.Vertex;
-import org.apache.commons.graph.VertexPair;
 import org.apache.commons.graph.model.BaseMutableGraph;
 import org.apache.commons.graph.model.DirectedMutableGraph;
 import org.apache.commons.graph.model.UndirectedMutableGraph;
@@ -40,16 +39,12 @@ final class VisitGraphBuilder<V extends 
 
     private BaseMutableGraph<V, E> visitGraph;
 
-    private Graph<V, E> graph;
-
     /**
      * {@inheritDoc}
      */
     @Override
     public void discoverGraph( Graph<V, E> graph )
     {
-        this.graph = graph;
-
         if ( graph instanceof DirectedGraph )
         {
             visitGraph = new DirectedMutableGraph<V, E>();
@@ -69,19 +64,9 @@ final class VisitGraphBuilder<V extends 
      * {@inheritDoc}
      */
     @Override
-    public void discoverEdge( E edge )
-    {
-        VertexPair<V> vertexPair = graph.getVertices( edge );
-        visitGraph.addEdge( vertexPair.getHead(), edge, vertexPair.getTail() );
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void finishGraph( Graph<V, E> graph )
+    public void discoverEdge( V head, E edge, V tail )
     {
-        this.graph = null;
+        visitGraph.addEdge( head, edge, tail );
     }
 
     /**



Mime
View raw message