mapss.dif.graph
Class BaseTopSortStrategy

java.lang.Object
  extended by mocgraph.analysis.strategy.CachedStrategy
      extended by mapss.dif.graph.BaseTopSortStrategy
All Implemented Interfaces:
TopSortAnalyzer, mocgraph.analysis.analyzer.Analyzer, mocgraph.analysis.analyzer.GraphAnalyzer
Direct Known Subclasses:
DFSTopSortStrategy, PartialTopSortStrategy, SDPPOTopSortStrategy

public class BaseTopSortStrategy
extends mocgraph.analysis.strategy.CachedStrategy
implements TopSortAnalyzer

A base class for topological sorting. This class merely provides common public function calls and does not perform topological sorting computation.

Version:
$Id: BaseTopSortStrategy.java 409 2007-05-13 19:47:16Z plishker $
Author:
Ming-Yung Ko
See Also:
TopSortAnalysis

Constructor Summary
BaseTopSortStrategy(mocgraph.Graph graph)
          Construct a top sorting strategy for a given graph.
 
Method Summary
protected  void _validate()
          Validate the graph for topological sorting.
 mocgraph.DirectedGraph directedGraph()
          Return the graph in the form of DirectedGraph.
 java.util.List topSort()
          Return a topological sorting order.
 java.lang.String toString()
          Return a description of the analysis in finding a top sorting order.
 boolean valid()
          Check compatibility of the class of graph.
 
Methods inherited from class mocgraph.analysis.strategy.CachedStrategy
_compute, _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 mocgraph.analysis.analyzer.GraphAnalyzer
graph
 

Constructor Detail

BaseTopSortStrategy

public BaseTopSortStrategy(mocgraph.Graph graph)
Construct a top sorting strategy for a given graph.

Parameters:
graph - The given graph.
Method Detail

directedGraph

public mocgraph.DirectedGraph directedGraph()
Return the graph in the form of DirectedGraph.

Returns:
The directed graph.

toString

public java.lang.String toString()
Return a description of the analysis in finding a top sorting order.

Specified by:
toString in interface mocgraph.analysis.analyzer.Analyzer
Overrides:
toString in class mocgraph.analysis.strategy.CachedStrategy
Returns:
A description of the analysis.

topSort

public java.util.List topSort()
Return a topological sorting order.

Specified by:
topSort in interface TopSortAnalyzer
Returns:
A topological sorting order.

valid

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

Specified by:
valid in interface mocgraph.analysis.analyzer.Analyzer
Returns:
True if the given graph is a directed acyclic graph (DAG).

_validate

protected void _validate()
Validate the graph for topological sorting. This method should be invoked right before the topological sorting computation in CachedStrategy._compute().

Throws:
java.lang.RuntimeException - will be thrown if valid() returns false.