how to find a route in a directed graph