// Textbook fragment 13.06 /** This class specializes DFS to determine whether the graph is connected. */ public class ConnectivityDFS extends DFS { protected int reached; protected void setup() { reached = 0; } protected void startVisit(Vertex v) { reached++; } protected Boolean finalResult(Boolean dfsResult) { return new Boolean(reached == graph.numVertices()); } }