Skip to content

Commit

Permalink
rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
anvaka committed Aug 14, 2023
1 parent 133f38e commit 4a564a2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions dist/ngraph.path.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ module.exports.l1 = heuristics.l1;
* @param {ngraph.graph} graph instance. See https://github.com/anvaka/ngraph.graph
*
* @param {Object} options that configures search
* @param {Function(a, b, link)} options.blocked - a function that returns `true` if the link between
* nodes `a` and `b` are blocked paths. This function is useful for temporarily blocking routes
* while allowing the graph to be reused without rebuilding.
* @param {Function(a, b)} options.heuristic - a function that returns estimated distance between
* nodes `a` and `b`. Defaults function returns 0, which makes this search equivalent to Dijkstra search.
* @param {Function(a, b)} options.distance - a function that returns actual distance between two
Expand Down Expand Up @@ -387,6 +390,9 @@ module.exports.l1 = heuristics.l1;
*
* @param {ngraph.graph} graph instance. See https://github.com/anvaka/ngraph.graph
* @param {Object} options that configures search
* @param {Function(a, b, link)} options.blocked - a function that returns `true` if the link between
* nodes `a` and `b` are blocked paths. This function is useful for temporarily blocking routes
* while allowing the graph to be reused without rebuilding.
* @param {Function(a, b)} options.heuristic - a function that returns estimated distance between
* nodes `a` and `b`. This function should never overestimate actual distance between two
* nodes (otherwise the found path will not be the shortest). Defaults function returns 0,
Expand Down Expand Up @@ -698,6 +704,9 @@ module.exports.l1 = heuristics.l1;
*
* @param {ngraph.graph} graph instance. See https://github.com/anvaka/ngraph.graph
* @param {Object} options that configures search
* @param {Function(a, b, link)} options.blocked - a function that returns `true` if the link between
* nodes `a` and `b` are blocked paths. This function is useful for temporarily blocking routes
* while allowing the graph to be reused without rebuilding.
* @param {Function(a, b)} options.heuristic - a function that returns estimated distance between
* nodes `a` and `b`. This function should never overestimate actual distance between two
* nodes (otherwise the found path will not be the shortest). Defaults function returns 0,
Expand All @@ -713,6 +722,9 @@ function nba(graph, options) {
var oriented = options.oriented;
var quitFast = options.quitFast;

var blocked = options.blocked;
if (!blocked) blocked = defaultSettings.blocked;

var heuristic = options.heuristic;
if (!heuristic) heuristic = defaultSettings.heuristic;

Expand Down Expand Up @@ -854,6 +866,8 @@ function nba(graph, options) {

if (otherSearchState.closed) return;

if (blocked(cameFrom.node, otherNode, link)) return;

var tentativeDistance = cameFrom.g1 + distance(cameFrom.node, otherNode, link);

if (tentativeDistance < otherSearchState.g1) {
Expand Down Expand Up @@ -882,6 +896,8 @@ function nba(graph, options) {

if (otherSearchState.closed) return;

if (blocked(cameFrom.node, otherNode, link)) return;

var tentativeDistance = cameFrom.g2 + distance(cameFrom.node, otherNode, link);

if (tentativeDistance < otherSearchState.g2) {
Expand Down
Loading

0 comments on commit 4a564a2

Please sign in to comment.