Class TextGraphWriter<V>

java.lang.Object
es.uam.eps.ir.relison.io.graph.TextGraphWriter<V>
Type Parameters:
V - Type of the vertices.
All Implemented Interfaces:
GraphWriter<V>

public class TextGraphWriter<V>
extends java.lang.Object
implements GraphWriter<V>
Writes a graph to a file.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    private java.lang.String delimiter
    The delimiter for separating fields.
  • Constructor Summary

    Constructors 
    Constructor Description
    TextGraphWriter​(java.lang.String delimiter)
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    boolean write​(Graph<V> graph, java.io.OutputStream file)
    Writes a graph into an output stream.
    boolean write​(Graph<V> graph, java.io.OutputStream file, boolean writeWeights, boolean writeTypes)
    Writes a graph into a output stream.
    boolean write​(Graph<V> graph, java.lang.String file)
    Writes a graph into a file.
    boolean write​(Graph<V> graph, java.lang.String file, boolean writeWeights, boolean writeTypes)
    Writes a graph into a file.
    private boolean writeMultiGraph​(MultiGraph<V> graph, java.io.BufferedWriter bw, boolean writeWeights, boolean writeTypes)
    Writes a multigraph into a file
    private boolean writeSimpleGraph​(Graph<V> graph, java.io.BufferedWriter bw, boolean writeWeights, boolean writeTypes)
    Writes a simple graph into a file

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • delimiter

      private final java.lang.String delimiter
      The delimiter for separating fields.
  • Constructor Details

    • TextGraphWriter

      public TextGraphWriter​(java.lang.String delimiter)
      Constructor.
      Parameters:
      delimiter - the delimiter for separating fields.
  • Method Details

    • write

      public boolean write​(Graph<V> graph, java.lang.String file)
      Description copied from interface: GraphWriter
      Writes a graph into a file. It writes the weights, but not the types
      Specified by:
      write in interface GraphWriter<V>
      Parameters:
      graph - The graph we want to write.
      file - The file.
      Returns:
      true if everything went OK, false otherwise.
    • write

      public boolean write​(Graph<V> graph, java.io.OutputStream file)
      Description copied from interface: GraphWriter
      Writes a graph into an output stream. It writes the weights, but not the types.
      Specified by:
      write in interface GraphWriter<V>
      Parameters:
      graph - The graph we want to write.
      file - The output stream.
      Returns:
      true if everything went OK, false otherwise.
    • write

      public boolean write​(Graph<V> graph, java.lang.String file, boolean writeWeights, boolean writeTypes)
      Description copied from interface: GraphWriter
      Writes a graph into a file. Simple graphs types are written, while multigraph types are not.
      Specified by:
      write in interface GraphWriter<V>
      Parameters:
      graph - The graph we want to write.
      file - The file.
      writeWeights - Indicates if weights have to be written.
      writeTypes - Indicates if types have to be written.
      Returns:
      true if everything is ok, false otherwise.
    • write

      public boolean write​(Graph<V> graph, java.io.OutputStream file, boolean writeWeights, boolean writeTypes)
      Description copied from interface: GraphWriter
      Writes a graph into a output stream. Simple graphs types are written, while multigraph types are not.
      Specified by:
      write in interface GraphWriter<V>
      Parameters:
      graph - The graph we want to write.
      file - The file.
      writeWeights - Indicates if weights have to be written.
      writeTypes - Indicates if types have to be written.
      Returns:
      true if everything is ok, false otherwise.
    • writeSimpleGraph

      private boolean writeSimpleGraph​(Graph<V> graph, java.io.BufferedWriter bw, boolean writeWeights, boolean writeTypes)
      Writes a simple graph into a file
      Parameters:
      graph - The simple graph we want to write
      bw - The file
      writeWeights - Indicates if weights have to be written or not.
      writeTypes - Indicates if types have to be written or not.
      Returns:
      true if everything went OK, false if not.
    • writeMultiGraph

      private boolean writeMultiGraph​(MultiGraph<V> graph, java.io.BufferedWriter bw, boolean writeWeights, boolean writeTypes)
      Writes a multigraph into a file
      Parameters:
      graph - The multigraph we want to write
      bw - the writer which will write the graph in the file
      writeWeights - Indicates if weights have to be written or not.
      writeTypes - Indicates if types have to be written or not.
      Returns:
      true if everything went OK, false if not.