Aggiunti alcuni esercizi
This commit is contained in:
@@ -12,7 +12,7 @@ import exceptions.InvalidKeyException;
|
||||
*/
|
||||
public class DFS<V, E, I, R> {
|
||||
protected Graph<V, E> graph; // The graph being traversed
|
||||
protected Vertex<V> start; // The start vertex for the DFS
|
||||
protected Vertex<V> start; // The start_static_methods vertex for the DFS
|
||||
protected I info; // Information object passed to DFS
|
||||
protected R visitResult; // The result of a recursive traversal call
|
||||
protected static Object STATUS = new Object(); // The status attribute
|
||||
@@ -22,7 +22,7 @@ public class DFS<V, E, I, R> {
|
||||
|
||||
|
||||
/** Execute a depth first search traversal on graph g, starting
|
||||
* from a start vertex s, passing in an information object (in) */
|
||||
* from a start_static_methods vertex s, passing in an information object (in) */
|
||||
public R execute(Graph<V, E> g, Vertex<V> s, I in) throws InvalidKeyException {
|
||||
graph = g;
|
||||
start = s;
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.security.InvalidKeyException;
|
||||
* <p>To execute the algorithm, use the {@link
|
||||
* #execute(Graph,Vertex,Object) execute} method, and then make
|
||||
* subsequent calls to the {@link #getDist(Vertex) getDist} method to
|
||||
* obtain the shortest distance from the start to any given vertex.
|
||||
* obtain the shortest distance from the start_static_methods to any given vertex.
|
||||
*
|
||||
* @author Roberto Tamassia, Michael Goodrich, Eric Zamore
|
||||
*/
|
||||
|
||||
@@ -46,7 +46,7 @@ public class FindCycleDFS<V, E>
|
||||
protected boolean isDone() { return done; }
|
||||
|
||||
public Iterable<Position> finalResult(Iterable<Position> r) {
|
||||
// remove the vertices and edges from start to cycleStart
|
||||
// remove the vertices and edges from start_static_methods to cycleStart
|
||||
if (!cycle.isEmpty()) {
|
||||
for (Position<Position> p: cycle.positions()) {
|
||||
if (p.element() == cycleStart)
|
||||
|
||||
@@ -5,11 +5,11 @@ import position.NodePositionList;
|
||||
import position.Position;
|
||||
import position.PositionList;
|
||||
|
||||
/** Class specializing DFS to find a path between a start vertex and a target
|
||||
/** Class specializing DFS to find a path between a start_static_methods vertex and a target
|
||||
* vertex. It assumes the target vertex is passed as the info object to the
|
||||
* execute method. It returns an iterable list of the vertices and edges
|
||||
* comprising the path from start to info. The returned path is empty if
|
||||
* info is unreachable from start. */
|
||||
* comprising the path from start_static_methods to info. The returned path is empty if
|
||||
* info is unreachable from start_static_methods. */
|
||||
public class FindPathDFS<V, E>
|
||||
extends DFS<V, E, Vertex<V>, Iterable<Position>> {
|
||||
protected PositionList<Position> path;
|
||||
@@ -27,7 +27,7 @@ public class FindPathDFS<V, E>
|
||||
}
|
||||
protected void finishVisit(Vertex<V> v) {
|
||||
path.remove(path.last()); // remove v from path
|
||||
if(!path.isEmpty()) // if v is not the start vertex
|
||||
if(!path.isEmpty()) // if v is not the start_static_methods vertex
|
||||
path.remove(path.last()); // remove discovery edge into v from path
|
||||
}
|
||||
protected void traverseDiscovery(Edge<E> e, Vertex<V> from) {
|
||||
|
||||
Reference in New Issue
Block a user