Saturday, November 14, 2015

BFS

Use bfs function included here.
https://github.com/prabushitha/DataStructures/blob/master/Graph/GraphBFS.py

Output:
bfs(graph,source) returns an array with shortest distances for each vertex in the graph
array element is None when there's no path

Usage:
If you want to print distances from 3 to other vertexes, call bfs function with the source vertex 3. print(bfs(graph,3))

No comments:

Post a Comment