Code coverage report for lib/algorithms/4-binaryTrees/isRoute.js

Statements: 93.75% (15 / 16)      Branches: 90% (9 / 10)      Functions: 100% (2 / 2)      Lines: 100% (13 / 13)      Ignored: none     

All files » lib/algorithms/4-binaryTrees/ » isRoute.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26    1   3   1 18 18   16   19   19 14 14 14       8       1
//4.2 Given a directed graph, determine if there is a route between two points
 
var isRoute = function(graph, me, you) {
 
	return isRoute(me, you) || isRoute(you, me);
 
	function isRoute(me, you) {
		Iif(me === null) return false;
		if(me === you) return true;
 
		for(var i = 0 , len = me.children.length; i < len; i ++)
		{
			var child = me.children[i];
 
			if(child.visited !== true) {
				child.visited = true;
				var found = isRoute(child, you);
				if(found === true) return true;
			}
		};
 
		return false;
	}
};
 
module.exports = isRoute;