Skip to content

@graphty/algorithms / index / heuristics

Variable: heuristics ​

const heuristics: object

Defined in: pathfinding/astar.ts:206

Common heuristic functions for A*

Type Declaration ​

chebyshev() ​

chebyshev: (a, b) => number

Chebyshev distance heuristic (diagonal movement allowed)

Parameters ​

a ​

[number, number]

First coordinate as [x, y] tuple

b ​

[number, number]

Second coordinate as [x, y] tuple

Returns ​

number

The Chebyshev distance between the two points

euclidean() ​

euclidean: (a, b) => number

Euclidean distance heuristic

Parameters ​

a ​

[number, number]

First coordinate as [x, y] tuple

b ​

[number, number]

Second coordinate as [x, y] tuple

Returns ​

number

The Euclidean distance between the two points

manhattan() ​

manhattan: (a, b) => number

Manhattan distance heuristic for grid-based graphs

Parameters ​

a ​

[number, number]

First coordinate as [x, y] tuple

b ​

[number, number]

Second coordinate as [x, y] tuple

Returns ​

number

The Manhattan distance between the two points

zero() ​

zero: <T>(_a, _b) => number

Zero heuristic (makes A* behave like Dijkstra)

Type Parameters ​

T ​

T

Parameters ​

_a ​

T

First node (unused)

_b ​

T

Second node (unused)

Returns ​

number

Always returns 0