Code For NonGeek
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Implementation of BFS

Go down

Implementation of BFS Empty Implementation of BFS

Post  Admin Sat Nov 05, 2011 5:47 pm

public void BFS(Node s){
for all v in V{
d[v]=infinity;
}
d[s]=0;
Queue<Node> F=new Queue<Node>();
F.euqueue(s);
while(!F.isEmpty()){
Node u=F.dequeue();
for (u,v) in E
if(d[v]>d[u]+weight(u,v)){
d[v]=d[u]+weight(u,v);
F.euqueue(v);
}
}
}

Admin
Admin

Posts : 131
Join date : 2011-08-16

https://codefornongeek.forumotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum