Implementation of BFS

View previous topic View next topic Go down

Implementation of BFS

Post  Admin on 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

View user profile http://codefornongeek.forumotion.com

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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