Some Good Reads:- 0-1 BFS Multi Source Shortest Path in Unweighted Graph Use BFS(queue) for unweighted graphs and Dijsktra(set) for weighted graphs. TO-DO Square-root Decomposition.