Here's an implementation of the A* algorithm in MATLAB:
main.m3175 chars78 lines
Note: This implementation assumes that the graph is represented as an adjacency matrix, where edges(i,j)
is the cost of going from node i
to node j
. It also assumes that the nodes are numbered from 1 to size(edges, 1)
. If your graph is represented differently, you'll need to modify the implementation accordingly. Additionally, this implementation uses Euclidean distance as the heuristic function. You can replace it with any other distance metric that makes sense for your problem.
gistlibby LogSnag