@osmix/router 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/algorithms/bidirectional.d.ts +19 -0
- package/dist/algorithms/bidirectional.d.ts.map +1 -0
- package/dist/algorithms/bidirectional.js +128 -0
- package/dist/algorithms/bidirectional.js.map +1 -0
- package/dist/algorithms/index.d.ts +17 -0
- package/dist/algorithms/index.d.ts.map +1 -0
- package/dist/algorithms/index.js +19 -0
- package/dist/algorithms/index.js.map +1 -0
- package/dist/algorithms/shortest-path.d.ts +24 -0
- package/dist/algorithms/shortest-path.d.ts.map +1 -0
- package/dist/algorithms/shortest-path.js +115 -0
- package/dist/algorithms/shortest-path.js.map +1 -0
- package/dist/binary-heap.d.ts +40 -0
- package/dist/binary-heap.d.ts.map +1 -0
- package/dist/binary-heap.js +122 -0
- package/dist/binary-heap.js.map +1 -0
- package/dist/graph.d.ts +135 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +339 -0
- package/dist/graph.js.map +1 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/router.d.ts +55 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +189 -0
- package/dist/router.js.map +1 -0
- package/dist/types.d.ts +118 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +20 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +101 -0
- package/dist/utils.js.map +1 -0
- package/package.json +10 -8
- package/tsconfig.build.json +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bidirectional breadth-first search algorithm.
|
|
3
|
+
*
|
|
4
|
+
* Searches from both start and end simultaneously, terminating when the
|
|
5
|
+
* frontiers meet. Very fast for finding any path, but does not guarantee
|
|
6
|
+
* the shortest path. Use Dijkstra or A* when optimality is required.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import type { RoutingAlgorithmFn } from "../types";
|
|
11
|
+
/**
|
|
12
|
+
* Bidirectional BFS - fast path finding from both ends.
|
|
13
|
+
*
|
|
14
|
+
* Uses breadth-first search from both start and end, terminating when
|
|
15
|
+
* the frontiers meet. Very fast for finding any path, though not always
|
|
16
|
+
* the optimal shortest path. Use Dijkstra or A* if optimality is required.
|
|
17
|
+
*/
|
|
18
|
+
export declare const bidirectional: RoutingAlgorithmFn;
|
|
19
|
+
//# sourceMappingURL=bidirectional.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bidirectional.d.ts","sourceRoot":"","sources":["../../src/algorithms/bidirectional.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAe,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAE/D;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,EAAE,kBA+H3B,CAAA"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bidirectional breadth-first search algorithm.
|
|
3
|
+
*
|
|
4
|
+
* Searches from both start and end simultaneously, terminating when the
|
|
5
|
+
* frontiers meet. Very fast for finding any path, but does not guarantee
|
|
6
|
+
* the shortest path. Use Dijkstra or A* when optimality is required.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Bidirectional BFS - fast path finding from both ends.
|
|
12
|
+
*
|
|
13
|
+
* Uses breadth-first search from both start and end, terminating when
|
|
14
|
+
* the frontiers meet. Very fast for finding any path, though not always
|
|
15
|
+
* the optimal shortest path. Use Dijkstra or A* if optimality is required.
|
|
16
|
+
*/
|
|
17
|
+
export const bidirectional = (graph, start, end, getWeight) => {
|
|
18
|
+
if (start === end)
|
|
19
|
+
return [{ nodeIndex: start, cost: 0 }];
|
|
20
|
+
// Forward search state
|
|
21
|
+
const fDist = new Map();
|
|
22
|
+
const fPrev = new Map();
|
|
23
|
+
const fQueue = [start];
|
|
24
|
+
// Backward search state
|
|
25
|
+
const bDist = new Map();
|
|
26
|
+
const bPrev = new Map();
|
|
27
|
+
const bQueue = [end];
|
|
28
|
+
fDist.set(start, 0);
|
|
29
|
+
bDist.set(end, 0);
|
|
30
|
+
let meetNode = null;
|
|
31
|
+
while (fQueue.length > 0 && bQueue.length > 0) {
|
|
32
|
+
// Expand forward
|
|
33
|
+
if (fQueue.length > 0) {
|
|
34
|
+
const current = fQueue.shift();
|
|
35
|
+
const currentD = fDist.get(current);
|
|
36
|
+
// Check if backward search reached this node
|
|
37
|
+
if (bDist.has(current)) {
|
|
38
|
+
meetNode = current;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
for (const edge of graph(current)) {
|
|
42
|
+
const neighbor = edge.targetNodeIndex;
|
|
43
|
+
if (fDist.has(neighbor))
|
|
44
|
+
continue;
|
|
45
|
+
const newD = currentD + getWeight(edge);
|
|
46
|
+
fDist.set(neighbor, newD);
|
|
47
|
+
fPrev.set(neighbor, {
|
|
48
|
+
nodeIndex: neighbor,
|
|
49
|
+
wayIndex: edge.wayIndex,
|
|
50
|
+
previousNodeIndex: current,
|
|
51
|
+
cost: newD,
|
|
52
|
+
});
|
|
53
|
+
fQueue.push(neighbor);
|
|
54
|
+
if (bDist.has(neighbor)) {
|
|
55
|
+
meetNode = neighbor;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (meetNode !== null)
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
// Expand backward
|
|
63
|
+
if (bQueue.length > 0) {
|
|
64
|
+
const current = bQueue.shift();
|
|
65
|
+
const currentD = bDist.get(current);
|
|
66
|
+
// Check if forward search reached this node
|
|
67
|
+
if (fDist.has(current)) {
|
|
68
|
+
meetNode = current;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
for (const edge of graph(current)) {
|
|
72
|
+
const neighbor = edge.targetNodeIndex;
|
|
73
|
+
if (bDist.has(neighbor))
|
|
74
|
+
continue;
|
|
75
|
+
const newD = currentD + getWeight(edge);
|
|
76
|
+
bDist.set(neighbor, newD);
|
|
77
|
+
bPrev.set(neighbor, {
|
|
78
|
+
nodeIndex: neighbor,
|
|
79
|
+
wayIndex: edge.wayIndex,
|
|
80
|
+
previousNodeIndex: current,
|
|
81
|
+
cost: newD,
|
|
82
|
+
});
|
|
83
|
+
bQueue.push(neighbor);
|
|
84
|
+
if (fDist.has(neighbor)) {
|
|
85
|
+
meetNode = neighbor;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (meetNode !== null)
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (meetNode === null)
|
|
94
|
+
return null;
|
|
95
|
+
// Build forward path: start -> meet
|
|
96
|
+
const forward = [];
|
|
97
|
+
let curr = meetNode;
|
|
98
|
+
while (curr !== undefined && curr !== start) {
|
|
99
|
+
const seg = fPrev.get(curr);
|
|
100
|
+
if (!seg)
|
|
101
|
+
break;
|
|
102
|
+
forward.unshift(seg);
|
|
103
|
+
curr = seg.previousNodeIndex;
|
|
104
|
+
}
|
|
105
|
+
forward.unshift({ nodeIndex: start, cost: 0 });
|
|
106
|
+
// Build backward path: meet -> end (reverse direction)
|
|
107
|
+
// bDist represents distance FROM end TO node, so it decreases as we approach end.
|
|
108
|
+
// Correct cost = forward cost to meet + (backward dist at meet - backward dist at curr)
|
|
109
|
+
const meetForwardCost = fDist.get(meetNode);
|
|
110
|
+
const meetBackwardCost = bDist.get(meetNode);
|
|
111
|
+
curr = meetNode;
|
|
112
|
+
while (curr !== undefined && curr !== end) {
|
|
113
|
+
const seg = bPrev.get(curr);
|
|
114
|
+
if (!seg)
|
|
115
|
+
break;
|
|
116
|
+
curr = seg.previousNodeIndex;
|
|
117
|
+
if (curr !== undefined) {
|
|
118
|
+
forward.push({
|
|
119
|
+
nodeIndex: curr,
|
|
120
|
+
wayIndex: seg.wayIndex,
|
|
121
|
+
previousNodeIndex: seg.nodeIndex,
|
|
122
|
+
cost: meetForwardCost + meetBackwardCost - (bDist.get(curr) ?? 0),
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return forward;
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=bidirectional.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bidirectional.js","sourceRoot":"","sources":["../../src/algorithms/bidirectional.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAuB,CAChD,KAAK,EACL,KAAK,EACL,GAAG,EACH,SAAS,EACR,EAAE;IACH,IAAI,KAAK,KAAK,GAAG;QAAE,OAAO,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAA;IAEzD,uBAAuB;IACvB,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAA;IACvC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAuB,CAAA;IAC5C,MAAM,MAAM,GAAa,CAAC,KAAK,CAAC,CAAA;IAEhC,wBAAwB;IACxB,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAA;IACvC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAuB,CAAA;IAC5C,MAAM,MAAM,GAAa,CAAC,GAAG,CAAC,CAAA;IAE9B,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IACnB,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;IAEjB,IAAI,QAAQ,GAAkB,IAAI,CAAA;IAElC,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,GAA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QACf,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QACpB,IAAI,GAAG,GAAG,CAAC,iBAAiB,CAAA;IAC7B,CAAC;IACD,OAAO,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAA;IAE9C,uDAAuD;IACvD,kFAAkF;IAClF,wFAAwF;IACxF,MAAM,eAAe,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAA;IAC5C,MAAM,gBAAgB,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAA;IAC7C,IAAI,GAAG,QAAQ,CAAA;IACf,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;QAC3C,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAC3B,IAAI,CAAC,GAAG;YAAE,MAAK;QACf,IAAI,GAAG,GAAG,CAAC,iBAAiB,CAAA;QAC5B,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC;gBACZ,SAAS,EAAE,IAAI;gBACf,QAAQ,EAAE,GAAG,CAAC,QAAQ;gBACtB,iBAAiB,EAAE,GAAG,CAAC,SAAS;gBAChC,IAAI,EAAE,eAAe,GAAG,gBAAgB,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACjE,CAAC,CAAA;QACH,CAAC;IACF,CAAC;IAED,OAAO,OAAO,CAAA;AACf,CAAC,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Routing algorithm implementations.
|
|
3
|
+
*
|
|
4
|
+
* Provides three algorithms:
|
|
5
|
+
* - `dijkstra`: Optimal shortest path, explores all directions equally.
|
|
6
|
+
* - `astar`: Optimal with heuristic guidance, faster for point-to-point.
|
|
7
|
+
* - `bidirectional`: Fast BFS from both ends, finds *a* path (not always optimal).
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import type { RoutingAlgorithm, RoutingAlgorithmFn } from "../types";
|
|
12
|
+
import { bidirectional } from "./bidirectional";
|
|
13
|
+
import { astar, dijkstra } from "./shortest-path";
|
|
14
|
+
export { astar, bidirectional, dijkstra };
|
|
15
|
+
export type { RoutingAlgorithmFn };
|
|
16
|
+
export declare const routingAlgorithms: Record<RoutingAlgorithm, RoutingAlgorithmFn>;
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/algorithms/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAA;AACzC,YAAY,EAAE,kBAAkB,EAAE,CAAA;AAElC,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,gBAAgB,EAAE,kBAAkB,CAI1E,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Routing algorithm implementations.
|
|
3
|
+
*
|
|
4
|
+
* Provides three algorithms:
|
|
5
|
+
* - `dijkstra`: Optimal shortest path, explores all directions equally.
|
|
6
|
+
* - `astar`: Optimal with heuristic guidance, faster for point-to-point.
|
|
7
|
+
* - `bidirectional`: Fast BFS from both ends, finds *a* path (not always optimal).
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import { bidirectional } from "./bidirectional";
|
|
12
|
+
import { astar, dijkstra } from "./shortest-path";
|
|
13
|
+
export { astar, bidirectional, dijkstra };
|
|
14
|
+
export const routingAlgorithms = {
|
|
15
|
+
dijkstra,
|
|
16
|
+
astar,
|
|
17
|
+
bidirectional,
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/algorithms/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAA;AAGzC,MAAM,CAAC,MAAM,iBAAiB,GAAiD;IAC9E,QAAQ;IACR,KAAK;IACL,aAAa;CACb,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shortest path algorithms (Dijkstra and A*).
|
|
3
|
+
*
|
|
4
|
+
* Both algorithms guarantee optimal paths. A* uses a heuristic to guide
|
|
5
|
+
* the search toward the destination, making it faster for most queries.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { RoutingAlgorithmFn } from "../types";
|
|
10
|
+
/**
|
|
11
|
+
* Dijkstra's algorithm - optimal shortest path without heuristic guidance.
|
|
12
|
+
* Explores nodes in order of increasing distance from start.
|
|
13
|
+
*/
|
|
14
|
+
export declare const dijkstra: RoutingAlgorithmFn;
|
|
15
|
+
/**
|
|
16
|
+
* A* algorithm - uses heuristic to guide search toward destination.
|
|
17
|
+
* Typically faster than Dijkstra for point-to-point queries.
|
|
18
|
+
*
|
|
19
|
+
* The heuristic is adapted based on the metric:
|
|
20
|
+
* - distance: haversine distance in meters
|
|
21
|
+
* - time: haversine distance / max speed (lower bound on travel time in seconds)
|
|
22
|
+
*/
|
|
23
|
+
export declare const astar: RoutingAlgorithmFn;
|
|
24
|
+
//# sourceMappingURL=shortest-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shortest-path.d.ts","sourceRoot":"","sources":["../../src/algorithms/shortest-path.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAA0B,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAkG1E;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,kBAEtB,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,EAAE,kBAuBnB,CAAA"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shortest path algorithms (Dijkstra and A*).
|
|
3
|
+
*
|
|
4
|
+
* Both algorithms guarantee optimal paths. A* uses a heuristic to guide
|
|
5
|
+
* the search toward the destination, making it faster for most queries.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { haversineDistance } from "@osmix/shared/haversine-distance";
|
|
10
|
+
import { BinaryHeap } from "../binary-heap";
|
|
11
|
+
/**
|
|
12
|
+
* Maximum speed (m/s) for time-based heuristic.
|
|
13
|
+
* Uses 130 km/h (~36.1 m/s) to ensure admissibility on all road types.
|
|
14
|
+
*/
|
|
15
|
+
const MAX_SPEED_MS = (130 * 1000) / 3600;
|
|
16
|
+
/**
|
|
17
|
+
* A* shortest path algorithm with configurable heuristic.
|
|
18
|
+
*
|
|
19
|
+
* When heuristic returns 0 for all nodes, this is equivalent to Dijkstra's algorithm.
|
|
20
|
+
* With an admissible heuristic (never overestimates), guarantees optimal paths.
|
|
21
|
+
*/
|
|
22
|
+
function shortestPath(graph, start, end, getWeight, heuristic) {
|
|
23
|
+
// Same node - trivial path
|
|
24
|
+
if (start === end)
|
|
25
|
+
return [{ nodeIndex: start, cost: 0 }];
|
|
26
|
+
const gScore = new Map(); // Best known cost to reach node
|
|
27
|
+
const previous = new Map(); // How we reached each node
|
|
28
|
+
const closed = new Set(); // Fully processed nodes
|
|
29
|
+
const heap = new BinaryHeap();
|
|
30
|
+
gScore.set(start, 0);
|
|
31
|
+
heap.push(start, heuristic(start));
|
|
32
|
+
while (heap.size > 0) {
|
|
33
|
+
const current = heap.pop();
|
|
34
|
+
// Reached destination
|
|
35
|
+
if (current === end)
|
|
36
|
+
return reconstructPath(previous, start, end);
|
|
37
|
+
// Already seen this node
|
|
38
|
+
if (closed.has(current))
|
|
39
|
+
continue;
|
|
40
|
+
closed.add(current);
|
|
41
|
+
const currentG = gScore.get(current);
|
|
42
|
+
for (const edge of graph(current)) {
|
|
43
|
+
const neighbor = edge.targetNodeIndex;
|
|
44
|
+
if (closed.has(neighbor))
|
|
45
|
+
continue;
|
|
46
|
+
const tentativeG = currentG + getWeight(edge);
|
|
47
|
+
const existingG = gScore.get(neighbor);
|
|
48
|
+
if (existingG === undefined || tentativeG < existingG) {
|
|
49
|
+
gScore.set(neighbor, tentativeG);
|
|
50
|
+
previous.set(neighbor, {
|
|
51
|
+
nodeIndex: neighbor,
|
|
52
|
+
wayIndex: edge.wayIndex,
|
|
53
|
+
previousNodeIndex: current,
|
|
54
|
+
cost: tentativeG,
|
|
55
|
+
});
|
|
56
|
+
const f = tentativeG + heuristic(neighbor);
|
|
57
|
+
heap.push(neighbor, f);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Reconstruct path from predecessor map.
|
|
65
|
+
*/
|
|
66
|
+
function reconstructPath(previous, start, end) {
|
|
67
|
+
const path = [];
|
|
68
|
+
let current = end;
|
|
69
|
+
while (current !== undefined) {
|
|
70
|
+
const segment = previous.get(current);
|
|
71
|
+
if (!segment) {
|
|
72
|
+
path.unshift({ nodeIndex: current, cost: 0 });
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
path.unshift(segment);
|
|
76
|
+
current = segment.previousNodeIndex;
|
|
77
|
+
}
|
|
78
|
+
if (path.length === 0 || path[0]?.nodeIndex !== start) {
|
|
79
|
+
path.unshift({ nodeIndex: start, cost: 0 });
|
|
80
|
+
}
|
|
81
|
+
return path;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Dijkstra's algorithm - optimal shortest path without heuristic guidance.
|
|
85
|
+
* Explores nodes in order of increasing distance from start.
|
|
86
|
+
*/
|
|
87
|
+
export const dijkstra = (graph, start, end, getWeight) => {
|
|
88
|
+
return shortestPath(graph, start, end, getWeight, () => 0);
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* A* algorithm - uses heuristic to guide search toward destination.
|
|
92
|
+
* Typically faster than Dijkstra for point-to-point queries.
|
|
93
|
+
*
|
|
94
|
+
* The heuristic is adapted based on the metric:
|
|
95
|
+
* - distance: haversine distance in meters
|
|
96
|
+
* - time: haversine distance / max speed (lower bound on travel time in seconds)
|
|
97
|
+
*/
|
|
98
|
+
export const astar = (graph, start, end, getWeight, getCoord, metric) => {
|
|
99
|
+
if (!getCoord)
|
|
100
|
+
return null;
|
|
101
|
+
const endCoord = getCoord(end);
|
|
102
|
+
if (!endCoord)
|
|
103
|
+
return null;
|
|
104
|
+
// Haversine heuristic scaled by metric
|
|
105
|
+
// For time: divide by max speed to get admissible time estimate
|
|
106
|
+
const heuristic = (nodeIndex) => {
|
|
107
|
+
const coord = getCoord(nodeIndex);
|
|
108
|
+
if (!coord)
|
|
109
|
+
return 0;
|
|
110
|
+
const distance = haversineDistance(endCoord, coord);
|
|
111
|
+
return metric === "time" ? distance / MAX_SPEED_MS : distance;
|
|
112
|
+
};
|
|
113
|
+
return shortestPath(graph, start, end, getWeight, heuristic);
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=shortest-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shortest-path.js","sourceRoot":"","sources":["../../src/algorithms/shortest-path.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,i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,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;AAC7D,CAAC,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Priority queue implementation for pathfinding algorithms.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Min-heap priority queue optimized for pathfinding.
|
|
7
|
+
*
|
|
8
|
+
* Uses a binary heap stored in a flat array for cache-friendly access.
|
|
9
|
+
* Tracks item positions to support O(log n) priority updates (decrease-key).
|
|
10
|
+
*
|
|
11
|
+
* Operations:
|
|
12
|
+
* - `push(item, priority)`: O(log n) - adds or updates item priority.
|
|
13
|
+
* - `pop()`: O(log n) - removes and returns minimum priority item.
|
|
14
|
+
* - `has(item)`: O(1) - checks if item is in heap.
|
|
15
|
+
*/
|
|
16
|
+
export declare class BinaryHeap {
|
|
17
|
+
private heap;
|
|
18
|
+
private priorities;
|
|
19
|
+
private positions;
|
|
20
|
+
get size(): number;
|
|
21
|
+
/**
|
|
22
|
+
* Add an item with given priority. If item exists, updates priority if lower.
|
|
23
|
+
*/
|
|
24
|
+
push(item: number, priority: number): void;
|
|
25
|
+
/**
|
|
26
|
+
* Remove and return the minimum-priority item.
|
|
27
|
+
*/
|
|
28
|
+
pop(): number | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Check if item is in the heap.
|
|
31
|
+
*/
|
|
32
|
+
has(item: number): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Clear all items.
|
|
35
|
+
*/
|
|
36
|
+
clear(): void;
|
|
37
|
+
private bubbleUp;
|
|
38
|
+
private bubbleDown;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=binary-heap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binary-heap.d.ts","sourceRoot":"","sources":["../src/binary-heap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;GAUG;AACH,qBAAa,UAAU;IACtB,OAAO,CAAC,IAAI,CAAe;IAC3B,OAAO,CAAC,UAAU,CAAe;IACjC,OAAO,CAAC,SAAS,CAAiC;IAElD,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAiB1C;;OAEG;IACH,GAAG,IAAI,MAAM,GAAG,SAAS;IAmBzB;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb,OAAO,CAAC,QAAQ;IAwBhB,OAAO,CAAC,UAAU;CAuClB"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Priority queue implementation for pathfinding algorithms.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Min-heap priority queue optimized for pathfinding.
|
|
7
|
+
*
|
|
8
|
+
* Uses a binary heap stored in a flat array for cache-friendly access.
|
|
9
|
+
* Tracks item positions to support O(log n) priority updates (decrease-key).
|
|
10
|
+
*
|
|
11
|
+
* Operations:
|
|
12
|
+
* - `push(item, priority)`: O(log n) - adds or updates item priority.
|
|
13
|
+
* - `pop()`: O(log n) - removes and returns minimum priority item.
|
|
14
|
+
* - `has(item)`: O(1) - checks if item is in heap.
|
|
15
|
+
*/
|
|
16
|
+
export class BinaryHeap {
|
|
17
|
+
heap = [];
|
|
18
|
+
priorities = [];
|
|
19
|
+
positions = new Map();
|
|
20
|
+
get size() {
|
|
21
|
+
return this.heap.length;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Add an item with given priority. If item exists, updates priority if lower.
|
|
25
|
+
*/
|
|
26
|
+
push(item, priority) {
|
|
27
|
+
const existing = this.positions.get(item);
|
|
28
|
+
if (existing !== undefined) {
|
|
29
|
+
if (priority < this.priorities[existing]) {
|
|
30
|
+
this.priorities[existing] = priority;
|
|
31
|
+
this.bubbleUp(existing);
|
|
32
|
+
}
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const index = this.heap.length;
|
|
36
|
+
this.heap.push(item);
|
|
37
|
+
this.priorities.push(priority);
|
|
38
|
+
this.positions.set(item, index);
|
|
39
|
+
this.bubbleUp(index);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Remove and return the minimum-priority item.
|
|
43
|
+
*/
|
|
44
|
+
pop() {
|
|
45
|
+
if (this.heap.length === 0)
|
|
46
|
+
return undefined;
|
|
47
|
+
const min = this.heap[0];
|
|
48
|
+
this.positions.delete(min);
|
|
49
|
+
const last = this.heap.pop();
|
|
50
|
+
const lastPriority = this.priorities.pop();
|
|
51
|
+
if (this.heap.length > 0) {
|
|
52
|
+
this.heap[0] = last;
|
|
53
|
+
this.priorities[0] = lastPriority;
|
|
54
|
+
this.positions.set(last, 0);
|
|
55
|
+
this.bubbleDown(0);
|
|
56
|
+
}
|
|
57
|
+
return min;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Check if item is in the heap.
|
|
61
|
+
*/
|
|
62
|
+
has(item) {
|
|
63
|
+
return this.positions.has(item);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Clear all items.
|
|
67
|
+
*/
|
|
68
|
+
clear() {
|
|
69
|
+
this.heap.length = 0;
|
|
70
|
+
this.priorities.length = 0;
|
|
71
|
+
this.positions.clear();
|
|
72
|
+
}
|
|
73
|
+
bubbleUp(startIndex) {
|
|
74
|
+
const item = this.heap[startIndex];
|
|
75
|
+
const priority = this.priorities[startIndex];
|
|
76
|
+
let index = startIndex;
|
|
77
|
+
while (index > 0) {
|
|
78
|
+
const parentIndex = (index - 1) >> 1;
|
|
79
|
+
const parentPriority = this.priorities[parentIndex];
|
|
80
|
+
if (priority >= parentPriority)
|
|
81
|
+
break;
|
|
82
|
+
// Swap with parent
|
|
83
|
+
this.heap[index] = this.heap[parentIndex];
|
|
84
|
+
this.priorities[index] = parentPriority;
|
|
85
|
+
this.positions.set(this.heap[index], index);
|
|
86
|
+
index = parentIndex;
|
|
87
|
+
}
|
|
88
|
+
this.heap[index] = item;
|
|
89
|
+
this.priorities[index] = priority;
|
|
90
|
+
this.positions.set(item, index);
|
|
91
|
+
}
|
|
92
|
+
bubbleDown(startIndex) {
|
|
93
|
+
const length = this.heap.length;
|
|
94
|
+
const item = this.heap[startIndex];
|
|
95
|
+
const priority = this.priorities[startIndex];
|
|
96
|
+
let index = startIndex;
|
|
97
|
+
while (true) {
|
|
98
|
+
const leftIndex = (index << 1) + 1;
|
|
99
|
+
const rightIndex = leftIndex + 1;
|
|
100
|
+
let smallest = index;
|
|
101
|
+
if (leftIndex < length &&
|
|
102
|
+
this.priorities[leftIndex] < this.priorities[smallest]) {
|
|
103
|
+
smallest = leftIndex;
|
|
104
|
+
}
|
|
105
|
+
if (rightIndex < length &&
|
|
106
|
+
this.priorities[rightIndex] < this.priorities[smallest]) {
|
|
107
|
+
smallest = rightIndex;
|
|
108
|
+
}
|
|
109
|
+
if (smallest === index)
|
|
110
|
+
break;
|
|
111
|
+
// Swap with smallest child
|
|
112
|
+
this.heap[index] = this.heap[smallest];
|
|
113
|
+
this.priorities[index] = this.priorities[smallest];
|
|
114
|
+
this.positions.set(this.heap[index], index);
|
|
115
|
+
index = smallest;
|
|
116
|
+
}
|
|
117
|
+
this.heap[index] = item;
|
|
118
|
+
this.priorities[index] = priority;
|
|
119
|
+
this.positions.set(item, index);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=binary-heap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binary-heap.js","sourceRoot":"","sources":["../src/binary-heap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,OAAO,UAAU;IACd,IAAI,GAAa,EAAE,CAAA;IACnB,UAAU,GAAa,EAAE,C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