has-path
Guide: /guide/algorithms/graph/has-path
Signature
ts
hasPath({ graph, from, to, traversalType });Params:
| Name | Type | Required | Description |
|---|---|---|---|
| graph | IGraph<T> | + | Graph to search |
| from | T | + | Start vertex |
| to | T | + | End vertex |
| traversalType | EnumGraphTraversalType | + | BFS, DFS, DIJKSTRA, BELLMAN_FORD, or A_STAR |
BELLMAN_FORD and A_STAR search with BFS. A reachable negative cycle still returns true.
Returns:
boolean
true when a path exists. false when the goal is in the graph and unreachable.