# BFS in K shortest paths

Do we need to use BFS or DFS algorithm to find the k shortest loopless paths in a graph between any two nodes? If so where can it be useful?

-
 What are your thoughts on the matter? A question as flat as this is unlikely to attract good answers. – Raphael♦ Jan 28 at 23:33

Consider the case $k=1$ first. Can you use BFS or DFS? Now try to generalize.

-
Can you elaborate a tad, maybe behind spoiler tags? As it stands, this answer is merely a comment. (A very helpful one, granted.) – Raphael Jan 28 at 10:06
That's a homework exercise, I don't want to solve other people's homework for them. I already passed the class. – Yuval Filmus Jan 28 at 14:35
If you're not happy with the answer, downvote it and/or write your own. Of late the site is full of homework questions by students too lazy to answer them on their own, trying their luck here, expecting us to do their work for them. Sometimes I feel like answering it anyway, sometimes not. This time I don't feel it. If that contradicts the homework policy, too bad. – Yuval Filmus Jan 28 at 22:47
You are not wrong (and I, as a user, often feel the same way), but again, that's not a reason to give poor answers (speaking as a mod). I also feel that "too bad" is not the response an experienced, integral member of the community should have when addressed for acting against established policy; do we need to talk about this on meta? – Raphael Jan 28 at 23:30
@Raphael the policy states that "this is my hw, what do i do" type of questions would be dealt with using quality control tools. i don't see this happening at all and the site is full of this kind of questions. – Sasho Nikolov Jan 29 at 1:24

For k=1.

I would like to draw your attention to the Theorem 22.5: Cormen
"upon termination d.v = ð(s,v) for all v € V"

ð(s,v) ... the minimum number of edges from s to v

-