File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,13 @@ var breadthFirstSearch = (function () {
4040 }
4141 }
4242
43+ /**
44+ * Process given node
45+ *
46+ * @param {number } destination The destionation, which should be reached
47+ * @param {number } current The current node
48+ * @param {number } node Neighbour node
49+ */
4350 function processNode ( destination , current , node ) {
4451 if ( graph [ current ] [ node ] ) {
4552 if ( node === destination ) {
@@ -70,7 +77,10 @@ var breadthFirstSearch = (function () {
7077 current = queue . shift ( ) ;
7178 visited [ current ] = true ;
7279 for ( var i = 0 ; i < graph . length ; i += 1 ) {
73- processNode ( destination , current , i ) ;
80+ var result = processNode ( destination , current , i ) ;
81+ if ( result ) {
82+ return true ;
83+ }
7484 }
7585 }
7686 return false ;
You can’t perform that action at this time.
0 commit comments