Class SerializedReaderWriter

  • All Implemented Interfaces:
    GraphReaderWriter, FileReaderWriter

    public class SerializedReaderWriter
    extends AbstractReaderWriter
    implements FileReaderWriter
    An implementation of GraphReaderWriter that uses java serialization to read and write graph objects. During the graph serialization process edges are written to the object output stream. Along with the edges, the two nodes incident to the edge are also written. However, edge adjacency lists of nodes are not written to the output stream in order to prevent deep recursive calls that often result in a stack overflow. Therefore it is important that any implementation of the Node interface declare its edge adjacecny list (if any) as transient in order to support graph serializability.
    Because edge adjacency lists are not serialized, they must be reconstructed upon deserialization in order to preserve the original graph structure.
    Author:
    Justin Deoliveira, Refractions Research Inc, jdeolive@refractions.net
    • Constructor Detail

      • SerializedReaderWriter

        public SerializedReaderWriter()
    • Method Detail

      • write

        public void write​(Graph graph)
                   throws Exception
        Serializes the graph by writing each edge in the graph to an object output stream. If there any nodes of degree 0 in the graph, then they are appended to the end of the object output stream.
        Specified by:
        write in interface GraphReaderWriter
        Parameters:
        graph - The graph to be
        Throws:
        Exception
        See Also:
        GraphReaderWriter#write()