























































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
























































Department of Computer Science — University of San Francisco – p.1/
Department of Computer Science — University of San Francisco – p.2/
class^ Edge {public int^ neighbor;public int^ next;} void^ DFS(Edge^ G[], int
vertex,^ boolean^ Visited[]) Edge tmp;Visited[vertex]^ = true;for (tmp =^ G[vertex];
tmp !=^ null; tmp^ = tmp.nex if (!Visited[tmp.neighbor])DFS(G,^ tmp.neighbor,
Visited); } }
Department of Computer Science — University of San Francisco – p.4/
Department of Computer Science — University of San Francisco – p.5/
DFS(0)^ DFS(1)^ Department of Computer Science — University of San Francisco – p.7/
DFS(0)^ DFS(1)^ DFS(3)^ Department of Computer Science — University of San Francisco – p.8/
DFS(0)^ DFS(1)^ DFS(3)^ DFS(4)^ DFS(2)^ Department of Computer Science — University of San Francisco – p.10/
DFS(0)^ DFS(1)^ DFS(3)^ DFS(4)^ DFS(2)^ DFS(5)^ Department of Computer Science — University of San Francisco – p.11/
int i;boolean Visited^ = new
Edge[G.length]; for (i=0;^ i<G.length;
i++) Visited[i]^ = false;for (i=0;^ i<G.length;
i++) if (!Visited[i])DFS(G,^ i, Visited);}
Department of Computer Science — University of San Francisco – p.13/
Department of Computer Science — University of San Francisco – p.16/
vertex,^ boolean^ Visited[]) Edge tmp;Visited[vertex]^ = true;for (tmp =^ G[vertex];
tmp !=^ null; tmp^ = tmp.nex if (!Visited[tmp.neighbor])DFS(G,^ tmp.neighbor,
Visited); } }
Department of Computer Science — University of San Francisco – p.17/
Department of Computer Science — University of San Francisco – p.19/