-1

I know that we can use BFS algorithm to find the shortest path between two nodes in a given unweighted and undirected graph .

But I am not sure whether it can also be used with unweighted and directed graph to find the shortest distance between the two nodes .

I have searched across different articles available online but I did not come across any article that answers my question .

Anyone please answer in Yes or No .

dd3012
  • 53
  • 7
  • Why wouldn't it? – kaya3 Aug 04 '22 at 19:14
  • @kaya3 That means it can be used with directed unweighted graph ,right ? – dd3012 Aug 04 '22 at 19:19
  • Looks like this is a homework question somewhere. – Sneftel Aug 04 '22 at 19:23
  • @kaya3 The linked question does not give a clear cut answer . I mean it does not say whether it can be used or not ? Please give a answer in yes/no and that is all i am asking for. – dd3012 Aug 04 '22 at 19:24
  • @Sneftel No, I am just asking it for my conceptual clarity. – dd3012 Aug 04 '22 at 19:25
  • 2
    How could the answer to the linked question be *more* clear? *"I mean it does not say whether it can be used or not ?"* But the answer literally includes the words "it can be used". If your issue is simply the absence of the word "yes" then I will just edit it in now. – kaya3 Aug 04 '22 at 19:27
  • How much clearer do you want? If the answer was unclear, why did you accept it? – beaker Aug 04 '22 at 19:37

2 Answers2

1

Yes, what changes is that you can only visit neighbors with an arrow from the current node.

Ahmad Othman
  • 106
  • 5
-2

I believe that BFS can be used though not alone. You will need a modified BFS approach since the shortest path wont inherently be the path path with least weight. I believe referring to this other answer will help you. Using BFS for Weighted Graphs