Skip to content

Instantly share code, notes, and snippets.

@Bekt
Last active December 10, 2015 00:19
Show Gist options
  • Save Bekt/4350540 to your computer and use it in GitHub Desktop.
Save Bekt/4350540 to your computer and use it in GitHub Desktop.
//http://coolcodebro.blogspot.com/2012/12/find-out-whether-there-is-route-between.html
boolean isRoute(Vertex source, Vertex target) {
if(source == null)
return false;
if(source.equals(target))
return true;
source.visited = true;
for (Edge edge : source.adj) {
if(!edge.target.visited) {
if(isRoute(edge.target, target))
return true;
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment