読者です 読者をやめる 読者になる 読者になる

Find out whether there is a routes between two nodes

Breadth First Search Graph Route Cracking The Coding Interview

Problem

Given a directed graph, design an algorithm to find out whether there is a route between two nodes.

How to Solve

This problem can be solved by depth first search or breadth first search. While traversing the graph, we have to control if the node is visited or not. Bellow code is a solution with BFS.