de.unihalle.informatik.MiToBo.io.files
Class GraphvizWriter<T extends java.lang.Comparable<?> & java.util.Comparator<?>>

java.lang.Object
  extended by de.unihalle.informatik.Alida.operator.ALDOperator
      extended by de.unihalle.informatik.MiToBo.io.files.GraphvizWriter<T>
Type Parameters:
T - Type of the nodes' data objects
All Implemented Interfaces:
de.unihalle.informatik.Alida.datatypes.ALDConfigurationValidator

@ALDAOperator(genericExecutionMode=NONE,
              level=STANDARD)
public class GraphvizWriter<T extends java.lang.Comparable<?> & java.util.Comparator<?>>
extends de.unihalle.informatik.Alida.operator.ALDOperator

Write graph to file using the DOT-language for visualization using graphviz tools. A main graph has to be specified whether as MTBGraph or AdjacencyMatrix. Further, subgraphs can be specified which then are painted in the specified color. If T is of type MatchingAdjacencyMatrix.NodeID, the nodes of each partition are drawn with same rank, i.e. they are lined up horizontally.

Author:
Oliver Gress

Nested Class Summary
 
Nested classes/interfaces inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.operator.ALDOperator.HidingMode
 
Field Summary
protected  AdjacencyMatrix<T> adjmatrix
           
private  boolean directed
           
protected  java.lang.String[] dotGlobalAttributes
           
protected  java.lang.String filename
           
protected  MTBGraph graph
           
protected  double maxWeight
           
private  java.util.HashMap<T,java.lang.String> nodeNames
           
private  boolean paintZeroWeightEdges
           
private  java.util.HashMap<T,java.util.TreeSet<T>> subgraphEdges
           
protected  java.util.Vector<MTBGraph> subgraphs
           
protected  java.util.Vector<AdjacencyMatrix<T>> subgraphs_adj
           
protected  java.util.Vector<java.awt.Color> subgraphs_adj_color
           
protected  java.util.Vector<java.awt.Color> subgraphs_color
           
protected  boolean weightAsEdgeThickness
           
 
Fields inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
completeDAG, name, portHashAccess, verbose, versionProvider
 
Constructor Summary
GraphvizWriter()
          Empty constructor
GraphvizWriter(AdjacencyMatrix<T> adjmatrix, java.lang.String filename)
          Constructor for specifying the graph by an adjacency matrix
GraphvizWriter(MTBGraph graph, java.lang.String filename)
          Constructor for specifying the graph by MTBGraph
 
Method Summary
 void addSubgraph(MTBGraph subgraph, java.awt.Color c)
          Specify a subgraph that is to be painted in the given color.
 void addSubgraphAdjaceny(AdjacencyMatrix<T> subgraph_adj, java.awt.Color c)
          Specify a subgraph that is to be painted in the given color.
private  void initNodeNames()
           
protected  void operate()
           
 void setAdjacencyMatrix(AdjacencyMatrix<T> adjmatrix)
          Set the main graph's adjacency matrix
 void setDotGlobalAttributes(java.lang.String[] dotGlobalAttributes)
          Set global attributes of the graph e.g. the style of the nodes etc.
 void setFilename(java.lang.String filename)
          Set the filename for output
 void setGraph(MTBGraph graph)
          Set the main graph using MTBGraph
 void setMaxWeight(double maxWeight)
          Specify the maximum weight in the graph.
 void setWeightAsEdgeThickness(boolean weightAsEdgeThickness)
          Set flag how edge weights are visualized.
 void validateCustom()
           
private  void writeGlobalAttributes(java.io.BufferedWriter w)
           
private  void writeGraph(java.io.BufferedWriter w)
           
private  void writeNodeLabels(java.io.BufferedWriter w)
           
private  void writePartitions(java.io.BufferedWriter w)
           
private  void writeSubgraphs(java.io.BufferedWriter w)
           
 
Methods inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
deserializeFromXmlFile, fieldContained, getALDPortHashAccessKey, getConstructionMode, getInInoutNames, getInInoutNames, getInNames, getInOutNames, getMissingRequiredInputs, getName, getNumParameters, getOutInoutNames, getOutNames, getParameter, getParameterDescriptor, getParameterNames, getSupplementalNames, getVerbose, getVersion, isConfigured, parametersToXmlObject, print, print, print, printInterface, printInterface, readHistory, readResolve, reinitializeParameterDescriptors, runOp, runOp, runOp, serializeToXmlFile, setConstructionMode, setName, setParameter, setParametersFromXml, setParametersFromXml, setVerbose, toStringVerbose, unconfiguredItems, validate, validateGeneric, writeHistory, writeHistory, writeHistory, writeParametersToXml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

adjmatrix

@Parameter(label="adjmatrix",
           direction=IN,
           required=false,
           description="Adjacency matrix of the input graph")
protected AdjacencyMatrix<T extends java.lang.Comparable<?> & java.util.Comparator<?>> adjmatrix

directed

private boolean directed

dotGlobalAttributes

@Parameter(label="dotGlobalAttributes",
           direction=IN,
           required=false,
           description="Global attributes for graph drawing (dot commands), e.g. node/edge style, color etc.")
protected java.lang.String[] dotGlobalAttributes

filename

@Parameter(label="filename",
           direction=IN,
           required=true,
           description="Output file name")
protected java.lang.String filename

graph

@Parameter(label="graph",
           direction=IN,
           required=false,
           description="Input graph")
protected MTBGraph graph

maxWeight

@Parameter(label="maxWeight",
           direction=IN,
           required=false,
           description="Maximum weight/cost in the graph, needed to limit edge thickness to 10pts if weights are visualized by edge thickness.")
protected double maxWeight

nodeNames

private java.util.HashMap<T extends java.lang.Comparable<?> & java.util.Comparator<?>,java.lang.String> nodeNames

paintZeroWeightEdges

private boolean paintZeroWeightEdges

subgraphEdges

private java.util.HashMap<T extends java.lang.Comparable<?> & java.util.Comparator<?>,java.util.TreeSet<T extends java.lang.Comparable<?> & java.util.Comparator<?>>> subgraphEdges

subgraphs

protected java.util.Vector<MTBGraph> subgraphs

subgraphs_adj

protected java.util.Vector<AdjacencyMatrix<T extends java.lang.Comparable<?> & java.util.Comparator<?>>> subgraphs_adj

subgraphs_adj_color

protected java.util.Vector<java.awt.Color> subgraphs_adj_color

subgraphs_color

protected java.util.Vector<java.awt.Color> subgraphs_color

weightAsEdgeThickness

@Parameter(label="weightAsEdgeThickness",
           direction=IN,
           required=true,
           description="Visualize weights by edge thickness")
protected boolean weightAsEdgeThickness
Constructor Detail

GraphvizWriter

public GraphvizWriter()
               throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Empty constructor

Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

GraphvizWriter

public GraphvizWriter(AdjacencyMatrix<T> adjmatrix,
                      java.lang.String filename)
               throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Constructor for specifying the graph by an adjacency matrix

Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

GraphvizWriter

public GraphvizWriter(MTBGraph graph,
                      java.lang.String filename)
               throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Constructor for specifying the graph by MTBGraph

Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Method Detail

addSubgraph

public void addSubgraph(MTBGraph subgraph,
                        java.awt.Color c)
Specify a subgraph that is to be painted in the given color.


addSubgraphAdjaceny

public void addSubgraphAdjaceny(AdjacencyMatrix<T> subgraph_adj,
                                java.awt.Color c)
Specify a subgraph that is to be painted in the given color.


initNodeNames

private void initNodeNames()

operate

protected void operate()
                throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                       de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Specified by:
operate in class de.unihalle.informatik.Alida.operator.ALDOperator
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

setAdjacencyMatrix

public void setAdjacencyMatrix(AdjacencyMatrix<T> adjmatrix)
Set the main graph's adjacency matrix


setDotGlobalAttributes

public void setDotGlobalAttributes(java.lang.String[] dotGlobalAttributes)
Set global attributes of the graph e.g. the style of the nodes etc. The given strings must match DOT-language commands, e.g 'node [style = "bold"];'.


setFilename

public void setFilename(java.lang.String filename)
Set the filename for output


setGraph

public void setGraph(MTBGraph graph)
Set the main graph using MTBGraph


setMaxWeight

public void setMaxWeight(double maxWeight)
Specify the maximum weight in the graph. This value is used to limit edge-thickness to 10 pts if weights are visualized by edge thickness (edgethickness = weight/maxWeight*10). Default is 1 !!


setWeightAsEdgeThickness

public void setWeightAsEdgeThickness(boolean weightAsEdgeThickness)
Set flag how edge weights are visualized. If flag is true weights are visualized by edge thickness, otherwise edges are labeled with the value of their weigth.


validateCustom

public void validateCustom()
                    throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Overrides:
validateCustom in class de.unihalle.informatik.Alida.operator.ALDOperator
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

writeGlobalAttributes

private void writeGlobalAttributes(java.io.BufferedWriter w)
                            throws java.io.IOException
Throws:
java.io.IOException

writeGraph

private void writeGraph(java.io.BufferedWriter w)
                 throws java.io.IOException
Throws:
java.io.IOException

writeNodeLabels

private void writeNodeLabels(java.io.BufferedWriter w)
                      throws java.io.IOException
Throws:
java.io.IOException

writePartitions

private void writePartitions(java.io.BufferedWriter w)
                      throws java.io.IOException
Throws:
java.io.IOException

writeSubgraphs

private void writeSubgraphs(java.io.BufferedWriter w)
                     throws java.io.IOException
Throws:
java.io.IOException