Methods
bfs(root, visit, getChildren) → {Object}
Perform a breadth-first search on a graph or tree.
Parameters:
Name | Type | Description |
---|---|---|
root |
Object
|
The root node to start the search from. |
visit |
function
|
A function to call for each visited node, return true to end up the search. |
getChildren |
function
|
A function to get the children of a node. |
Returns:
- Type:
-
Object
The node found
dfs(root, visit, getChildren) → {Object}
Perform a depth-first search on a graph or tree.
Parameters:
Name | Type | Description |
---|---|---|
root |
Object
|
The root node to start the search from. |
visit |
function
|
A function to call for each visited node, return true to end up the search. |
getChildren |
function
|
A function to get the children of a node. |
Returns:
- Type:
-
Object
The node found