Answer:
The answer is This should be possible in O(m+n) with BFS.
Explanation:
Give us a chance to take your chart G. Complete a BFS on the diagram. Check every one of the hubs in the diagrams as visited as normal with BFS. Rather than adding only hubs to the line in the DFS include hubs in addition to number of incoming ways. On the off chance that a hub that has been visited ought to be included disregard it. On the off chance that you discover a hub again which is as of now present in your line don't include it once more, rather include the checks together. Proliferate the depends on the line while including new hubs when you experience the last hub i.e the goal hub the number that is put away with it is the quantity of briefest ways in the diagram.