Static findFinds shortest path between two nodes using BFS
adjacency list representation of the graph
starting node
ending node
array representing the shortest path, or null if no path exists
Static hasStatic nodesFinds all nodes at a given distance from the start node
adjacency list representation of the graph
starting node
distance from start node
array of nodes at the given distance
Static traverseGenerated using TypeDoc
Breadth-First Search (BFS) algorithm BFS is an algorithm for traversing or searching tree or graph data structures. It starts at a chosen node and explores all neighbor nodes at the present depth before moving on to nodes at the next depth level.
Time Complexity: O(V + E) where V is vertices and E is edges Space Complexity: O(V)
Example