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

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

public class DotExporter<V extends GraphIONode,E>
extends java.lang.Object

Exports a SimGraph to a .dot file, either in clustered mode or in "plain" mode. In clustered mode, nodes are grouped and shown inside visual "boxes". The nodes in the graph must implement GraphIONode.

Links are drawn always as undirected (no arrows).

The appeareace of elements in the output file (link weights, node labels, colors, etc) is controlled through two separate mechanisms:

Unless setFormatter(GraphFormatter) is called, the formatting is based on the basic, property-based mechanism. In this case, link capacity and residual capacity is assumed to be 1, and link weight=0.0 for all links.

The purpose of this class is to support "quick visual exploration" of graphs. If you are interested layouts that are more visually appealing than the ones generated by GraphViz, consider using the software Visone for example.

Author:
Juan Segovia S.

Constructor Summary
DotExporter(java.lang.String fname, SimGraph<V,E> g, java.lang.String prop)
          Creates a new instance and saves the parameters for later use.
DotExporter(java.io.Writer wr, SimGraph<V,E> g, java.lang.String prop)
          Same as DotExporter(String, SimGraph, String) but the output goes to parameter wr instead.
 
Method Summary
 void export(java.util.Map<E,? extends java.lang.Number> thickness)
          Write .dot output in plain (non-clustered) mode.
 void exportClustered(java.util.Map<java.lang.Integer,java.util.List<V>> clusters, java.util.Map<java.lang.Integer,java.lang.String> clust_labels, java.util.Map<E,? extends java.lang.Number> thickness)
          Write .dot output in "clustered" mode, i.e., with subgraphs.
 void printf(java.lang.String fmt, java.lang.Object... args)
          Writes a formatted string to the output stream.
 void setFormatter(GraphFormatter<V,E> formatter)
          Sets an explicit formatter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DotExporter

public DotExporter(java.lang.String fname,
                   SimGraph<V,E> g,
                   java.lang.String prop)
Creates a new instance and saves the parameters for later use.

Parameters:
fname - the name of the output file.
g - the graph to export.
prop - is a comma-separated list of property=value pairs. n and l correspond to node and link, respectively. See PropertyBasedFormatter for more details on these two properties.

For example, with
  prop="heading=SomeBigTopology,n=il,l=wrc"
the resulting .dot file will "SomeBigTopology" for heading, each node will have a description of the form "nn-text", each link will have "cap=nn, res=yy, w=zz" (for link capacity, residual capacity and weight).

Any part in prop is optional; position is irrelevant. See PropertyBasedFormatter for further details.


DotExporter

public DotExporter(java.io.Writer wr,
                   SimGraph<V,E> g,
                   java.lang.String prop)
Same as DotExporter(String, SimGraph, String) but the output goes to parameter wr instead.

Method Detail

setFormatter

public void setFormatter(GraphFormatter<V,E> formatter)
Sets an explicit formatter.


exportClustered

public void exportClustered(java.util.Map<java.lang.Integer,java.util.List<V>> clusters,
                            java.util.Map<java.lang.Integer,java.lang.String> clust_labels,
                            java.util.Map<E,? extends java.lang.Number> thickness)
Write .dot output in "clustered" mode, i.e., with subgraphs.

Parameters:
clusters - gives the list of nodes included in each cluster.
clust_labels - a string to print at the top of each box that visually define a cluster.
thickness - the relative thickness of each link.

See export(Map) for more details.


export

public void export(java.util.Map<E,? extends java.lang.Number> thickness)
Write .dot output in plain (non-clustered) mode.

Parameters:
thickness - gives the desired line width for each link. This can be used, for example, to visually compare the residual capacity of links. The parameter thickness can be null, in which case no "penwidth" attribute is given for the .dot ouput.

If any link has no entry in this map, a penwidth=1 is used.

Under the "basic" formatting mechanism, when ls=% (ls means "link suffix"), the thickness values are assumed to be percentages and thus already properly "scaled". The link with mhe highest percentage is shown with penwidth=12.

The title for the .dot graph, i.e., the "label" attribute of the graph in the .dot file, is always taken from the "heading" property in the parameter prop of the constructors, that is setFormatter() has no influence on this.


printf

public void printf(java.lang.String fmt,
                   java.lang.Object... args)
Writes a formatted string to the output stream.

Throws:
AnyException - when any IOException occurs. The original exception is wrapped.