>>841
コードの意図がよく分からん。正しいともいえるし間違ってるともいえる。

この辺見るよろし
ttp://www-fs.informatik.uni-tuebingen.de/~hueffner/

可能ならこの記事で参照してる以下の論文を入手して読むこと
P. E. Hart, N. J. Nilsson, and B. Raphael. A formal basis for the
heuristic determination of minimum cost paths. IEEE Transactions on
Systems Science and Cybernetics, SSC-4(2):100-107, 1968