Package ptolemy.graph.analysis
Class MirrorTransformation
- java.lang.Object
-
- ptolemy.graph.analysis.Analysis
-
- 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)
andoriginalVersionOf(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 aCloneNotSupportedException
will be thrown by the virtual machine.- Since:
- Ptolemy II 4.0
- Version:
- $Id$
- Author:
- Shahrooz Shahparnia
- Pt.AcceptedRating:
- Red (ssb)
- Pt.ProposedRating:
- Red (shahrooz)
-
-
Constructor Summary
Constructors Constructor Description MirrorTransformation(MirrorTransformer analyzer)
Construct a transformation for a given graph and a given analyzer.MirrorTransformation(Graph graph)
Construct a transformation for a given graph with a default analyzer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cloneWeight(boolean status)
Changes the status of the graph returned by themirror()
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
-
-
-
-
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 themirror()
method. If true, the weights will also be cloned in the next calls to themirror()
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.
-
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 classAnalysis
- Parameters:
analyzer
- The given analyzer.- Returns:
- True if the given analyzer is valid for this analysis.
-
-