ptolemy.graph.analysis
Class MirrorTransformation

java.lang.Object
  extended by ptolemy.graph.analysis.Analysis
      extended by ptolemy.graph.analysis.MirrorTransformation

public class MirrorTransformation
extends Analysis

A mirror transformations on graphs. Creates a mirror of this graph in the form of the type of the associated graph. The mirror and original graphs are isomorphic(of same topology). However, node and edge objects of the mirror are newly created and therefore not "equal" to those of the original graph.

To relate nodes and edges from the original and the mirrored graph the transformedVersionOf(java.lang.Object) and originalVersionOf(java.lang.Object) methods are provided. Labels can also be used to relate mirror and original nodes(edges).

In the cloneWeight(boolean) method, users can also specify whether to clone node and edge weights. For non cloneable weights a CloneNotSupportedException will be thrown by the virtual machine.

Since:
Ptolemy II 4.0
Version:
$Id: MirrorTransformation.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Shahrooz Shahparnia
Accepted Rating:
Red (ssb)
Proposed Rating:
Red (shahrooz)

Constructor Summary
MirrorTransformation(Graph graph)
          Construct a transformation for a given graph with a default analyzer.
MirrorTransformation(MirrorTransformer analyzer)
          Construct a transformation for a given graph and a given analyzer.
 
Method Summary
 void cloneWeight(boolean status)
          Changes the status of the graph returned by the mirror() method.
 boolean hasBackwardMapping()
          Specify if this transformation has a mapping from the transformed version to the original version or not.
 boolean hasForwardMapping()
          Specify if this transformation has a mapping from the original version to the transformed version or not.
 Graph mirror()
          Create a mirror of the graph associated with this analyzer with the same runtime class.
 Graph mirror(Graph graph, boolean cloneWeights)
          Return a mirror of this graph in the form of the argument graph type (i.e., the run-time type of the returned graph is that of the argument graph).
 java.lang.Object originalVersionOf(java.lang.Object transformedObject)
          Return the original version of given object in the transformed graph.
 java.lang.String toString()
          Return a description of the analysis and the associated analyzer.
 java.lang.Object transformedVersionOf(java.lang.Object originalObject)
          Return the transformed version of a given object in the original graph.
 boolean validAnalyzerInterface(Analyzer analyzer)
          Check if a given analyzer is compatible with this analysis.
 
Methods inherited from class ptolemy.graph.analysis.Analysis
analyzer, changeAnalyzer, graph, valid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MirrorTransformation

public MirrorTransformation(Graph graph)
Construct a transformation for a given graph with a default analyzer. The default constructor runs in O(N+E) in which N is the number of nodes in the graph and E is the number of edges in the graph.

Parameters:
graph - The given graph.

MirrorTransformation

public MirrorTransformation(MirrorTransformer analyzer)
Construct a transformation for a given graph and a given analyzer.

Parameters:
analyzer - The default Analyzer.
Method Detail

cloneWeight

public void cloneWeight(boolean status)
Changes the status of the graph returned by the mirror() method. If true, the weights will also be cloned in the next calls to the mirror() method.

Parameters:
status - If true, the weights will also be cloned.

hasBackwardMapping

public boolean hasBackwardMapping()
Specify if this transformation has a mapping from the transformed version to the original version or not.

Returns:
True if the implementation of the transformer supports backward mapping.

hasForwardMapping

public boolean hasForwardMapping()
Specify if this transformation has a mapping from the original version to the transformed version or not.

Returns:
True if the implementation of the transformer supports forward mapping.

mirror

public Graph mirror()
Create a mirror of the graph associated with this analyzer with the same runtime class.

Returns:
The mirror graph.

mirror

public Graph mirror(Graph graph,
                    boolean cloneWeights)
Return a mirror of this graph in the form of the argument graph type (i.e., the run-time type of the returned graph is that of the argument graph).

In this method, users can also specify whether to clone node and edge weights.

Parameters:
graph - The graph.
cloneWeights - True if the weights will also be cloned.
Returns:
The mirror graph.

originalVersionOf

public java.lang.Object originalVersionOf(java.lang.Object transformedObject)
Return the original version of given object in the transformed graph.

Parameters:
transformedObject - The given object in the transformed graph.
Returns:
Return the original version the given object.

toString

public java.lang.String toString()
Return a description of the analysis and the associated analyzer.

Overrides:
toString in class Analysis
Returns:
A description of the analysis and the associated analyzer.

transformedVersionOf

public java.lang.Object transformedVersionOf(java.lang.Object originalObject)
Return the transformed version of a given object in the original graph.

Parameters:
originalObject - The given object in the original graph.
Returns:
Return the transformed version of the given object.

validAnalyzerInterface

public boolean validAnalyzerInterface(Analyzer analyzer)
Check if a given analyzer is compatible with this analysis. In other words if it is possible to use it to compute the computation associated with this analysis.

Overrides:
validAnalyzerInterface in class Analysis
Parameters:
analyzer - The given analyzer.
Returns:
True if the given analyzer is valid for this analysis.