new BFS(graph, source, target)
Constructs a BFS algorithm object.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
graph |
Graph | null | The graph. |
source |
Number | The node index of the source node. |
|
target |
Number | The node index of the target node. |
Members
-
found :Boolean
-
Whether the search was successful or not.
- Default Value:
- false
-
nullable graph :Graph
-
The graph.
- Default Value:
- null
-
source :Number
-
The node index of the source node.
- Default Value:
- - 1
-
target :Number
-
The node index of the target node.
- Default Value:
- - 1
Methods
-
clear() → {BFS}
-
Clears the internal state of the object. A new search is now possible.
-
getPath() → {Array.<Number>}
-
Returns the shortest path from the source to the target node as an array of node indices.
Returns:
Array.<Number> -The shortest path.
-
getSearchTree() → {Array.<Edge>}
-
Returns the search tree of the algorithm as an array of edges.
-
search() → {BFS}
-
Executes the graph search. If the search was successful, BFS#found is set to true.