Skip to content
This repository has been archived by the owner on Apr 26, 2019. It is now read-only.

Commit

Permalink
path: avoid fruitless work when the target node is not reachable
Browse files Browse the repository at this point in the history
  • Loading branch information
kortschak committed Jun 29, 2015
1 parent e0082ef commit 1ee26d8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion path/a_star.go
Expand Up @@ -33,7 +33,7 @@ type HeuristicCoster interface {
// falling back to NullHeuristic otherwise. If the graph does not implement graph.Weighter,
// graph.UniformCost is used. AStar will panic if g has an A*-reachable negative edge weight.
func AStar(s, t graph.Node, g graph.Graph, h Heuristic) (path Shortest, expanded int) {
if !g.Has(s) {
if !g.Has(s) || !g.Has(t) {
return Shortest{from: s}, 0
}
var weight graph.WeightFunc
Expand Down

0 comments on commit 1ee26d8

Please sign in to comment.