You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2012/02/04 16:32:05 UTC

svn commit: r1240520 - in /commons/sandbox/graph/trunk/src: changes/ main/java/org/apache/commons/graph/ main/java/org/apache/commons/graph/model/ main/java/org/apache/commons/graph/spanning/

Author: simonetripodi
Date: Sat Feb  4 15:32:05 2012
New Revision: 1240520

URL: http://svn.apache.org/viewvc?rev=1240520&view=rev
Log:
[SANDBOX-384] Make Graph components Serializable

Modified:
    commons/sandbox/graph/trunk/src/changes/changes.xml
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/Edge.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/Graph.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/Vertex.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledEdge.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledVertex.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java
    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
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableWeightedGraph.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryPath.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryWeightedPath.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/MutableSpanningTree.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/RevertedGraph.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/UndirectedMutableGraph.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/UndirectedMutableWeightedGraph.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/ReverseDeleteGraph.java

Modified: commons/sandbox/graph/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/changes/changes.xml?rev=1240520&r1=1240519&r2=1240520&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/changes/changes.xml (original)
+++ commons/sandbox/graph/trunk/src/changes/changes.xml Sat Feb  4 15:32:05 2012
@@ -23,6 +23,9 @@
   </properties>
   <body>
   <release version="0.1" date="201?-??-??" description="First release.">
+    <action dev="simonetripodi" type="fix" issue="SANDBOX-384">
+      Make Graph components Serializable
+    </action>
     <action dev="simonetripodi" type="fix" issue="SANDBOX-384" due-to="Marco Speranza">
       Add test for Flow Algorithms
     </action>

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/Edge.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/Edge.java?rev=1240520&r1=1240519&r2=1240520&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/Edge.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/Edge.java Sat Feb  4 15:32:05 2012
@@ -1,5 +1,7 @@
 package org.apache.commons.graph;
 
+import java.io.Serializable;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -28,6 +30,7 @@ package org.apache.commons.graph;
  * intended from {@link #getHead()} to {@link #getTail()}.
  */
 public interface Edge
+    extends Serializable
 {
 
 }

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/Graph.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/Graph.java?rev=1240520&r1=1240519&r2=1240520&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/Graph.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/Graph.java Sat Feb  4 15:32:05 2012
@@ -1,5 +1,7 @@
 package org.apache.commons.graph;
 
+import java.io.Serializable;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -23,11 +25,12 @@ package org.apache.commons.graph;
  * A Graph data structure consists of a finite (and possibly mutable) set of ordered pairs, called {@link Edge}s or
  * arcs, of certain entities called {@link Vertex} or node. As in mathematics, an {@link Edge} {@code (x,y)} is said to
  * point or go from {@code x} to {@code y}.
- * 
+ *
  * @param <V> the Graph vertices type
  * @param <E> the Graph edges type
  */
 public interface Graph<V extends Vertex, E extends Edge>
+    extends Serializable
 {
 
     /**

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/Vertex.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/Vertex.java?rev=1240520&r1=1240519&r2=1240520&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/Vertex.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/Vertex.java Sat Feb  4 15:32:05 2012
@@ -1,5 +1,7 @@
 package org.apache.commons.graph;
 
+import java.io.Serializable;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -23,5 +25,6 @@ package org.apache.commons.graph;
  * A Vertex or Node is the fundamental unit out of which graphs are formed.
  */
 public interface Vertex
+    extends Serializable
 {
 }

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java?rev=1240520&r1=1240519&r2=1240520&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseGraph.java Sat Feb  4 15:32:05 2012
@@ -35,7 +35,7 @@ import org.apache.commons.graph.VertexPa
 /**
  * Basic abstract in-memory based of a simple read-only {@link Graph} implementation. Subclasses may load adjacency
  * list/edges set in the constructor, or expose {@link org.apache.commons.graph.MutableGraph} APIs.
- * 
+ *
  * @param <V> the Graph vertices type
  * @param <E> the Graph edges type
  */
@@ -43,6 +43,8 @@ public abstract class BaseGraph<V extend
     implements Graph<V, E>
 {
 
+    private static final long serialVersionUID = -8066786787634472712L;
+
     private final Map<V, Set<V>> adjacencyList = new HashMap<V, Set<V>>();
 
     private final Set<E> allEdges = new HashSet<E>();
@@ -109,7 +111,7 @@ public abstract class BaseGraph<V extend
 
     /**
      * Returns the adjacency list where stored vertex/edges.
-     * 
+     *
      * @return the adjacency list where stored vertex/edges.
      */
     protected final Map<V, Set<V>> getAdjacencyList()

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledEdge.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledEdge.java?rev=1240520&r1=1240519&r2=1240520&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledEdge.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledEdge.java Sat Feb  4 15:32:05 2012
@@ -29,6 +29,8 @@ public class BaseLabeledEdge
     implements Edge, Labeled
 {
 
+    private static final long serialVersionUID = 1L;
+
     private final String label;
 
     public BaseLabeledEdge( String label )

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledVertex.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledVertex.java?rev=1240520&r1=1240519&r2=1240520&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledVertex.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledVertex.java Sat Feb  4 15:32:05 2012
@@ -29,6 +29,8 @@ public class BaseLabeledVertex
     implements Labeled, Vertex
 {
 
+    private static final long serialVersionUID = 1895831541078075882L;
+
     private final String label;
 
     public BaseLabeledVertex( String label )

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java?rev=1240520&r1=1240519&r2=1240520&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java Sat Feb  4 15:32:05 2012
@@ -32,6 +32,8 @@ public class BaseLabeledWeightedEdge<W>
     implements WeightedEdge<W>
 {
 
+    private static final long serialVersionUID = 4093288823907255359L;
+
     private final W weight;
 
     public BaseLabeledWeightedEdge( String label, W weight )

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=1240520&r1=1240519&r2=1240520&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 Feb  4 15:32:05 2012
@@ -39,6 +39,8 @@ public abstract class BaseMutableGraph<V
     implements MutableGraph<V, E>
 {
 
+    private static final long serialVersionUID = 1549113549446254183L;
+
     /**
      * {@inheritDoc}
      */
@@ -88,7 +90,7 @@ public abstract class BaseMutableGraph<V
     }
 
     /**
-     * 
+     *
      *
      * @param v
      */
@@ -120,7 +122,7 @@ public abstract class BaseMutableGraph<V
         {
             throw new GraphException( "Tail Vertex '%s' not present in the Graph", tail );
         }
-        
+
         if ( getEdge( head, tail ) != null )
         {
             throw new GraphException( "Edge %s is already present in the Graph", e );
@@ -147,7 +149,7 @@ public abstract class BaseMutableGraph<V
     }
 
     /**
-     * 
+     *
      *
      * @param e
      */
@@ -169,7 +171,7 @@ public abstract class BaseMutableGraph<V
     }
 
     /**
-     * 
+     *
      *
      * @param 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=1240520&r1=1240519&r2=1240520&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 Feb  4 15:32:05 2012
@@ -39,6 +39,8 @@ public class DirectedMutableGraph<V exte
     implements DirectedGraph<V, E>
 {
 
+    private static final long serialVersionUID = 630111985439492792L;
+
     private final Map<V, Set<V>> inbound = new HashMap<V, Set<V>>();
 
     private final Map<V, Set<V>> outbound = new HashMap<V, Set<V>>();

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableWeightedGraph.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableWeightedGraph.java?rev=1240520&r1=1240519&r2=1240520&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableWeightedGraph.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/DirectedMutableWeightedGraph.java Sat Feb  4 15:32:05 2012
@@ -32,4 +32,6 @@ public class DirectedMutableWeightedGrap
     extends DirectedMutableGraph<V, WE>
 {
 
+    private static final long serialVersionUID = 3749802534265570596L;
+
 }

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryPath.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryPath.java?rev=1240520&r1=1240519&r2=1240520&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryPath.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryPath.java Sat Feb  4 15:32:05 2012
@@ -46,6 +46,8 @@ public class InMemoryPath<V extends Vert
     implements Path<V, E>
 {
 
+    private static final long serialVersionUID = -7248626031673230570L;
+
     private final V source;
 
     private final V target;

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryWeightedPath.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryWeightedPath.java?rev=1240520&r1=1240519&r2=1240520&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryWeightedPath.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InMemoryWeightedPath.java Sat Feb  4 15:32:05 2012
@@ -39,7 +39,13 @@ public final class InMemoryWeightedPath<
     implements WeightedPath<V, WE, W>
 {
 
+    /**
+     *
+     */
+    private static final long serialVersionUID = 7937494144459068796L;
+
     private W weight;
+
     private Monoid<W> monoid;
 
     public InMemoryWeightedPath( V start, V target, Monoid<W> monoid )

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/MutableSpanningTree.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/MutableSpanningTree.java?rev=1240520&r1=1240519&r2=1240520&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/MutableSpanningTree.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/MutableSpanningTree.java Sat Feb  4 15:32:05 2012
@@ -36,15 +36,16 @@ public final class MutableSpanningTree<V
     implements SpanningTree<V, WE, W>
 {
 
+    private static final long serialVersionUID = -4371938772248573879L;
+
     private Monoid<W> monoid;
+
     private W weight;
-    
+
     public MutableSpanningTree(Monoid<W> monoid) {
         this.monoid = monoid;
         this.weight = monoid.zero();
     }
-    
-
 
     /**
      * {@inheritDoc}

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/RevertedGraph.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/RevertedGraph.java?rev=1240520&r1=1240519&r2=1240520&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/RevertedGraph.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/RevertedGraph.java Sat Feb  4 15:32:05 2012
@@ -37,6 +37,8 @@ public final class RevertedGraph<V exten
     implements DirectedGraph<V, E>
 {
 
+    private static final long serialVersionUID = 5867643705350331891L;
+
     /**
      * The DirectedGraph has to be adapted.
      */

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/UndirectedMutableGraph.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/UndirectedMutableGraph.java?rev=1240520&r1=1240519&r2=1240520&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/UndirectedMutableGraph.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/UndirectedMutableGraph.java Sat Feb  4 15:32:05 2012
@@ -34,6 +34,8 @@ public class UndirectedMutableGraph<V ex
     implements UndirectedGraph<V, E>
 {
 
+    private static final long serialVersionUID = 3067145277295525946L;
+
     /**
      * {@inheritDoc}
      */

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/UndirectedMutableWeightedGraph.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/UndirectedMutableWeightedGraph.java?rev=1240520&r1=1240519&r2=1240520&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/UndirectedMutableWeightedGraph.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/UndirectedMutableWeightedGraph.java Sat Feb  4 15:32:05 2012
@@ -32,4 +32,6 @@ public class UndirectedMutableWeightedGr
     extends UndirectedMutableGraph<V, WE>
 {
 
+    private static final long serialVersionUID = -4846482321351740099L;
+
 }

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/ReverseDeleteGraph.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/ReverseDeleteGraph.java?rev=1240520&r1=1240519&r2=1240520&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/ReverseDeleteGraph.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/spanning/ReverseDeleteGraph.java Sat Feb  4 15:32:05 2012
@@ -38,6 +38,8 @@ final class ReverseDeleteGraph<V extends
     implements Graph<V, WE>
 {
 
+    private static final long serialVersionUID = -543197749473412325L;
+
     private final Graph<V, WE> graph;
 
     private final List<WE> sortedEdge;