Skip to content

Code implicitly assumes that the heuristic output is of the same type as the graph weights. #143

Closed
@p-w-rs

Description

@p-w-rs

When using A* I was attempting to use a heuristic function that return a float, but the default weights of the graph were ints.

Here is the example

using Graphs, LinearAlgebra, Random
Random.seed!(0)

xyz = rand(4000, 3)
g = random_regular_graph(4000, 4)
src = rand(1:4000)
dst = rand(1:4000)
h(v) = Int(round(norm(xyz[v, :] - xyz[dst, :])))
edges = a_star(g, src, dst, weights(g), h)

# The above works since I convert to int, below does not, I get InexactError: Int64(1.7553136893610342)

h(v) = norm(xyz[v, :] - xyz[dst, :])
edges = a_star(g, src, dst, weights(g), h)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions