edu.claflin.finder.io.graph

## Class SimpleGraphIO

- java.lang.Object
- - edu.claflin.finder.io.graph.SimpleGraphIO

- All Implemented Interfaces:
    GraphReader, GraphWriter

      public final class SimpleGraphIO
      extends java.lang.Object
      implements GraphReader, GraphWriter

  A class for reading and writing graphs.
  Version:
    3.1.2 February 2, 2016
  Author:
    Charles Allen Schultz II

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleGraphIO()` Empty Constructor for instantiating the class.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Graph` | `parseGraph(java.io.File source, boolean undirected)` Reads a graph from memory.
    `private static boolean` | `testFile(java.io.File file)` Tests to see if a File is a valid graph file.
    `void` | `writeGraph(Graph toWrite)` Writes graphs to memory.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SimpleGraphIO

          public SimpleGraphIO()

      Empty Constructor for instantiating the class. No customization necessary.

  - ### Method Detail

    - #### parseGraph

          public Graph parseGraph(java.io.File source,
                                  boolean undirected)

      Reads a graph from memory. Reads simple tab delimited graphs. A graph file consists of an edge on each line with a tab delimiting the two nodes joined by the edge and followed by an integer value representing the edge weight.
      Specified by:
        `parseGraph` in interface `GraphReader`
      Parameters:
        `source` - the File object representing the graph.
        `undirected` - a boolean indicating if the graph should be interpreted as undirected.
      Returns:
        the Graph object parsed from the file.

    - #### writeGraph

          public void writeGraph(Graph toWrite)

      Writes graphs to memory. Writes simple tab delimited graphs. Outputs to the disk a graph. Each line of the outputted graph represents an edge. The two nodes joined by the edge are delimited by a tab.
      Specified by:
        `writeGraph` in interface `GraphWriter`
      Parameters:
        `toWrite` - the `Graph` object to write to a file.

    - #### testFile

          private static boolean testFile(java.io.File file)

      Tests to see if a File is a valid graph file. Currently only tests by checking to ensure the provided file is not a directory.
      Parameters:
        `file` - the File to test.
      Returns:
        the boolean value representing if the file is valid.