10 Ocak 2010 Pazar

Depth First Traversal in Graphs Algorithm

Graphlarda derinliğe göre dolaşma algoritması: (Recursive)

depthFirst(weightMatrice w,int v,boolean[]visited)
{
visited[v]=true;
print(v.label)
int[] connections=w.neighbors(v);

for i=0 to connectios.length i++
int n=connections[i];

if(!visited[n])
depthFirst(w,n,visited);
end loop
}

v=start of traversal

source code download

pseudo code by tyln

Hiç yorum yok:

Yorum Gönder