// Textbook fragment 13.04 /** Generic DFS traversal of a graph using the template method pattern. * A subclass should override various methods to add functionality. * Parameterized types: * V, the type for the elements stored at vertices * E, the type for the elements stored at edges * I, the type for the information object passed to the execute method * R, the type for the result object returned by the DFS */ public class DFS { protected Graph graph; // The graph being traversed protected Vertex start; // The start 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 protected static Object VISITED = new Object(); // Visited value protected static Object UNVISITED = new Object(); // Unvisited value