Algorithm DFS(v)
//Given an undirected (directed) graph
//G=(v,E) with n vertices and an array visited[] initially set to zero
//ther algorithm visits all vertices reachable from v. G and visited are global.
{
visited[v]:=1;
for each vertex w adjacent from v do
{
if(visited[w]=0) then DFS(w);
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment