Author: simonetripodi
Date: Sat Jun 18 00:10:43 2011
New Revision: 1137093

URL: http://svn.apache.org/viewvc?rev=1137093&view=rev
Log:
discriminated ingoing/outgoing edges in directed graph, adjacency list used to 
store all edges

Modified:
    
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseMutableGraph.java
    
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableGraph.java

Modified: 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseMutableGraph.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseMutableGraph.java?rev=1137093&r1=1137092&r2=1137093&view=diff
==============================================================================
--- 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseMutableGraph.java
 (original)
+++ 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseMutableGraph.java
 Sat Jun 18 00:10:43 2011
@@ -101,6 +101,7 @@ public abstract class BaseMutableGraph<V
 
         getAllEdges().add( e );
         getAdjacencyList().get( e.getHead() ).add( e );
+        getAdjacencyList().get( e.getTail() ).add( e );
 
         decorateAddEdge( e );
     }
@@ -121,6 +122,7 @@ public abstract class BaseMutableGraph<V
 
         getAllEdges().remove( e );
         getAdjacencyList().get( e.getHead() ).remove( e );
+        getAdjacencyList().get( e.getTail() ).remove( e );
 
         decorateRemoveEdge( e );
     }

Modified: 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableGraph.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableGraph.java?rev=1137093&r1=1137092&r2=1137093&view=diff
==============================================================================
--- 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableGraph.java
 (original)
+++ 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableGraph.java
 Sat Jun 18 00:10:43 2011
@@ -41,6 +41,8 @@ public class DirectedMutableGraph<V exte
 
     private final Map<V, Set<E>> inbound = new HashMap<V, Set<E>>();
 
+    private final Map<V, Set<E>> outbound = new HashMap<V, Set<E>>();
+
     /**
      * {@inheritDoc}
      */
@@ -54,7 +56,7 @@ public class DirectedMutableGraph<V exte
      */
     public Set<E> getOutbound( V v )
     {
-        return getAdjacencyList().get( v );
+        return outbound.get( v );
     }
 
     /**
@@ -64,6 +66,7 @@ public class DirectedMutableGraph<V exte
     protected void decorateAddVertex( V v )
     {
         inbound.put( v, new HashSet<E>() );
+        outbound.put( v, new HashSet<E>() );
     }
 
     /**
@@ -73,6 +76,7 @@ public class DirectedMutableGraph<V exte
     protected void decorateRemoveVertex( V v )
     {
         inbound.remove( v );
+        outbound.remove( v );
     }
 
     /**
@@ -82,6 +86,7 @@ public class DirectedMutableGraph<V exte
     protected void decorateAddEdge( E e )
     {
         inbound.get( e.getTail() ).add( e );
+        outbound.get( e.getHead() ).add( e );
     }
 
     /**
@@ -91,6 +96,7 @@ public class DirectedMutableGraph<V exte
     protected void decorateRemoveEdge( E e )
     {
         inbound.get( e.getTail() ).remove( e );
+        outbound.get( e.getHead() ).remove( e );
     }
 
 }


Reply via email to