/** * Method to do the DFS traversal - Recursive call * * @param u: Vertex for which the DFS checks the adjacency list. * @param cno: Count variable to keep the number of connected components. */ static void dfsVisit(Vertex u, int cno) { u.seen = true; u.cno = cno; for (Edge e : u.Adj) { Vertex v = e.otherEnd(u); if (!v.seen) { v.parent = u; dfsVisit(v, cno); } } }