Does anyone have an implementation of the A* algorithm in PHP? I know that wikipedia has a pseudocode and a link to a C++ one, but I can't seem to find one already written in PHP.

I am also looking for an efficient written A* algorithm

Comments

I bet linking to the algorithm in your question would help anyone that feels ambitious to make a port. -- EDIT: http://en.wikipedia.org/wiki/A*_search_algorithm

Written by Brad Christie

there's nothing there, it's a wiki page...

Written by aherlambang

@Equinox: It drops the * in the URL. Add it back after the A, it should work.

Written by Brad Christie

I know, but that's not a PHP implementation... saw that link already

Written by aherlambang

Sounds kind of easy enough to write, once you understand it. (youtube.com/watch?v=Kw8AMmyc6vg)

Written by Brad Christie

The speed of A* depends a lot on your datastructure. Your question is impossible to answer if you don't explain what your datastructure looks like. once you've cleared that out and have your heuristic function ready it's really as simple as porting the pseudo-code from the wikipedia page mentioned by Brad.

Written by kritzikratzi

what do you mean by data structure here? the set of nodes - edge? If that's the case then I have that already in the database as nodes - edge

Written by aherlambang

Accepted Answer

Written by aaz
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki