Here's an implementation of the A-star algorithm in Python:
main.py759 chars26 linesThis implementation assumes that the graph is represented using a class with the following methods:
neighbors(node): returns the list of neighbors of nodecost(node, next): returns the cost of the edge connecting node to nextheuristic(node, goal): returns the estimated cost from node to the goalThese methods need to be implemented according to the particular problem that you're trying to solve.
gistlibby LogSnag