マツシタのお勉強

Find out whether there is a routes between two nodes

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.