ptolemy.graph.analysis.strategy
Class SourceNodeStrategy

java.lang.Object
  extended by ptolemy.graph.analysis.strategy.Strategy
      extended by ptolemy.graph.analysis.strategy.CachedStrategy
          extended by ptolemy.graph.analysis.strategy.SourceNodeStrategy
All Implemented Interfaces:
Analyzer, GraphAnalyzer, SourceNodeAnalyzer

public class SourceNodeStrategy
extends CachedStrategy
implements SourceNodeAnalyzer

Computation of source nodes in a graph. The collection returned cannot be modified.

This analysis requires O(N) time, where N is the number of nodes in the graph.

Since:
Ptolemy II 4.0
Version:
$Id: SourceNodeStrategy.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Ming Yung Ko, Shahrooz Shahparnia
See Also:
SourceNodeAnalysis
Accepted Rating:
Red (ssb)
Proposed Rating:
Red (shahrooz)

Constructor Summary
SourceNodeStrategy(Graph graph)
          Construct an instance of this strategy for a given graph.
 
Method Summary
protected  java.lang.Object _compute()
          Compute the source nodes in the graph in the form of a collection.
protected  java.lang.Object _convertResult()
          Return the result of this analysis (collection of source nodes) in a form that cannot be modified.
 java.util.List nodes()
          Compute the source nodes in the graph in the form of a collection.
 java.lang.String toString()
          Return a description of the analyzer.
 boolean valid()
          Check compatibility of the class of graph.
 
Methods inherited from class ptolemy.graph.analysis.strategy.CachedStrategy
_convertResult, _result, cachingStatus, disableCaching, enableCaching, getCachedResult, graph, obsolete, reset, setCachedResult
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ptolemy.graph.analysis.analyzer.GraphAnalyzer
graph
 

Constructor Detail

SourceNodeStrategy

public SourceNodeStrategy(Graph graph)
Construct an instance of this strategy for a given graph.

Parameters:
graph - The given graph.
Method Detail

nodes

public java.util.List nodes()
Compute the source nodes in the graph in the form of a collection. Each element of the collection is a Node.

Specified by:
nodes in interface SourceNodeAnalyzer
Returns:
The source nodes.

toString

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

Specified by:
toString in interface Analyzer
Overrides:
toString in class CachedStrategy
Returns:
Return a description of the analyzer..

valid

public boolean valid()
Check compatibility of the class of graph. The given graph must be an instance of DirectedGraph.

Specified by:
valid in interface Analyzer
Returns:
True if the given graph is of class DirectedGraph.

_compute

protected java.lang.Object _compute()
Compute the source nodes in the graph in the form of a collection. Each element of the collection is a Node.

Overrides:
_compute in class CachedStrategy
Returns:
The source nodes.

_convertResult

protected java.lang.Object _convertResult()
Return the result of this analysis (collection of source nodes) in a form that cannot be modified.

Returns:
The analysis result in unmodifiable form.