bcds.phison.io
Class GraphMLWriter<V extends GraphIONode,E>

java.lang.Object
  extended by bcds.phison.io.GraphWriter<V,E>
      extended by bcds.phison.io.GraphMLWriter<V,E>

public class GraphMLWriter<V extends GraphIONode,E>
extends GraphWriter<V,E>

Writes a SimGraph to a GraphML file. The nodes of the graph to be exported must implement GraphIONode. The primary purpose of this class is to attain minimal interoperability with other software packages that can read the GraphML. That is, the most important information conveyed in the output file is the adjacency matrix. Beyond that, no effort is made to harmonize attribute names or types with other packages.

The node attributes written are: xcoord (int), ycoord (int), and label (string).

The edge attributes written are: capacity (int) and cost (float). The cost attribute is written only if the cost map is not null (see GraphWriter.setCostMap(Map)).

The traffic matrix is never written, that is, it is silently discarded.

The GraphML file format is described here.

Author:
Juan Segovia S.

Constructor Summary
GraphMLWriter(SimGraph<V,E> g)
          Creates a new writer instance for the graph g and sets the output to System.out.
GraphMLWriter(java.lang.String fname, SimGraph<V,E> g)
          Creates a new writer instance for the graph g and sets the output to the file fname.
GraphMLWriter(java.io.Writer out, SimGraph<V,E> g)
          Creates a new writer instance for the graph g and sets the output to out.
 
Method Summary
 void writeAll()
          Writes the full GrapphML file.
 
Methods inherited from class bcds.phison.io.GraphWriter
printf, setCapacityMap, setCostMap, setHeadingComment, setNetName, setTrafficMatrix, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphMLWriter

public GraphMLWriter(SimGraph<V,E> g)
Creates a new writer instance for the graph g and sets the output to System.out.


GraphMLWriter

public GraphMLWriter(java.lang.String fname,
                     SimGraph<V,E> g)
Creates a new writer instance for the graph g and sets the output to the file fname.

Throws:
AnyException - if an IO error occurs during file opening/creation.

GraphMLWriter

public GraphMLWriter(java.io.Writer out,
                     SimGraph<V,E> g)
Creates a new writer instance for the graph g and sets the output to out.

Method Detail

writeAll

public void writeAll()
Writes the full GrapphML file. Calls writeHeader(), writeNodes() and writeEdges() in sequence, followed by a flush.

Throws:
AnyException - wrapping an IOExeption if any IO error occurs.