Implement breadth-first search on a graph and return the shortest path length from a source node to all reachable nodes.