gshute.graph
Class SpanningTreeRecorder

java.lang.Object
  |
  +--gshute.graph.SpanningTreeRecorder

public class SpanningTreeRecorder
extends java.lang.Object
implements GraphSearchRecorder

A SpanningTreeRecorder, when attached to a graph searcher, constructs spanning trees for graphs.

In addition to implementing the methods of the GraphSearchRecorder interface, a spanning tree recorder provides the method getViaEdge() to retrieve the search edge that led to a vertex.


Field Summary
protected  java.util.Map viaEdges
          viaEdges is the table of via edges for this spanning tree generator.
 
Constructor Summary
SpanningTreeRecorder()
           
 
Method Summary
 void endSearch()
          rcrdr.endSearch() performs any necessary cleanup after a search.
 java.lang.Object getVia(java.lang.Object ov)
          rcrdr.getVia(ov) is called after a graph search using rcrdr to get the edge that led to ov in the search.
 boolean isVisited(java.lang.Object ov)
          rcrdr.isVisited(ov) returns true if ov has been visited in a graph search using rcrdr.
 void revisit(java.lang.Object v, java.lang.Object via)
          revisit(v, via) records that v has been revisited, arriving at v through edge via.
 void startSearch(SearchableGraph sg)
          rcrdr.startSearch(sg) clears all recording of via edges in rcrdr.
 boolean visit(java.lang.Object ov, java.lang.Object ovia)
          rcrdr.visit(ov, ovia) records in rcrdr that ov has been visited through edge ovia.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

viaEdges

protected java.util.Map viaEdges
viaEdges is the table of via edges for this spanning tree generator.
Constructor Detail

SpanningTreeRecorder

public SpanningTreeRecorder()
Method Detail

startSearch

public void startSearch(SearchableGraph sg)
rcrdr.startSearch(sg) clears all recording of via edges in rcrdr.
Specified by:
startSearch in interface GraphSearchRecorder

isVisited

public boolean isVisited(java.lang.Object ov)
rcrdr.isVisited(ov) returns true if ov has been visited in a graph search using rcrdr.
Specified by:
isVisited in interface GraphSearchRecorder

visit

public boolean visit(java.lang.Object ov,
                     java.lang.Object ovia)
rcrdr.visit(ov, ovia) records in rcrdr that ov has been visited through edge ovia. This implementation of the method always returns false so that the search will continue until the dispenser is empty.
Specified by:
visit in interface GraphSearchRecorder

revisit

public void revisit(java.lang.Object v,
                    java.lang.Object via)
revisit(v, via) records that v has been revisited, arriving at v through edge via. This implementation of the method does not do anything.
Specified by:
revisit in interface GraphSearchRecorder

endSearch

public void endSearch()
rcrdr.endSearch() performs any necessary cleanup after a search. This implementation of the method does not do anything.
Specified by:
endSearch in interface GraphSearchRecorder

getVia

public java.lang.Object getVia(java.lang.Object ov)
rcrdr.getVia(ov) is called after a graph search using rcrdr to get the edge that led to ov in the search. If ov was not reached in the search or if ov was the start vertex of the search then the call returns null.