Search this API

y.io
Class TGFIOHandler

java.lang.Object
  extended by y.io.IOHandler
      extended by y.io.TGFIOHandler

public class TGFIOHandler
extends IOHandler

Reads and Writes a Graph2D in a trivial graph format (TGF).

The TGF format can only read and write the structure of a graph, but not the graphical attributes associated with its nodes and edges. Therefore upon reading a graph all nodes and edges will be initialized with default realizer objects provided by Graph2D.

TGF has the following format:

 file =    node_list 
           #
           edge_list 

  node_list = node_item   node_list   |   node_item | []
  node_item = node_id   [node_name] 
  edge_list = edge_item   edge_list   |   edge_item 
  edge_item = source_node_id   target_node_id [edge_name]      
  source_node_id = node_id 
  target_node_id = node_id
  
 An example with 10 nodes is the following:

 1  a node 
 2  another node
 3  yet another node
 4  another one
 5  and again
 6  again
 7  again
 8  again
 9  almost there
 10 last node 
 # 
 2  1 
 2  3 
 4  3 
 5  4 
 5  1 
 3  1  
 2  4 
 5  3 
 4  1 
 2  5 
 6  1 
 7  6 
 8  7 
 2  8 
 9  1 
 10 9 
 2  10 
 
 

The example above corresponds to the graph structure depicted below:

 

Constructor Summary
TGFIOHandler()
          Instantiates a new TGFIOHandler.
 
Method Summary
 boolean getAssignEdgeLabels()
          Returns whether or not to ignore node labels when reading or writing nodes.
 boolean getAssignNodeLabels()
          Returns whether or not to ignore node labels when reading or writing nodes.
 java.lang.String getFileFormatString()
          Returns the TGF file format string.
 java.lang.String getFileNameExtension()
          Returns the TGF file name extension, i.e.
 void read(Graph2D graph, java.io.InputStream in)
          Fills the contents of the given graph from an input stream.
 void setIgnoreEdgeLabels(boolean ignore)
          Whether or not to ignore edge labels when reading or writing edges.
 void setIgnoreNodeLabels(boolean ignore)
          Whether or not to ignore node labels when reading or writing nodes.
 void write(Graph2D graph, java.io.OutputStream out)
          Writes the contents of the given graph in TGF format to a stream.
 
Methods inherited from class y.io.IOHandler
canRead, canWrite, canWriteSubset, createObjectInputStream, createObjectOutputStream, hide, read, read, shouldSerialize, shouldSerialize, write, writeSubset, writeSubset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TGFIOHandler

public TGFIOHandler()
Instantiates a new TGFIOHandler.

Method Detail

setIgnoreNodeLabels

public void setIgnoreNodeLabels(boolean ignore)
Whether or not to ignore node labels when reading or writing nodes.


setIgnoreEdgeLabels

public void setIgnoreEdgeLabels(boolean ignore)
Whether or not to ignore edge labels when reading or writing edges.


getAssignNodeLabels

public boolean getAssignNodeLabels()
Returns whether or not to ignore node labels when reading or writing nodes.

The default setting is false


getAssignEdgeLabels

public boolean getAssignEdgeLabels()
Returns whether or not to ignore node labels when reading or writing nodes.

The default setting is true


getFileFormatString

public java.lang.String getFileFormatString()
Returns the TGF file format string.

Specified by:
getFileFormatString in class IOHandler

getFileNameExtension

public java.lang.String getFileNameExtension()
Returns the TGF file name extension, i.e. "tgf"

Specified by:
getFileNameExtension in class IOHandler

read

public void read(Graph2D graph,
                 java.io.InputStream in)
          throws java.io.IOException
Fills the contents of the given graph from an input stream.

Specified by:
read in class IOHandler
Parameters:
in - The input stream being read from
Throws:
java.io.IOException

write

public void write(Graph2D graph,
                  java.io.OutputStream out)
           throws java.io.IOException
Writes the contents of the given graph in TGF format to a stream.

Specified by:
write in class IOHandler
Parameters:
out - The OutputStream being written to.
Throws:
java.io.IOException

© Copyright 2000-2021,
yWorks GmbH.
All rights reserved.