How do we ensure that we get the shortest path for every node
HOLI Spoj solution
Hey Rhytham
A rather interesting question !
If you see carefully, the graph is a tree so there exists only one unique path between any 2 nodes which is always the shortest.