Next: 9.3 ヒューリスティック関数
Up: 9 見込み探索
Previous: 9.1 頂点の座標空間
頂点間の距離は頂点を引数として以下の関数で求めることができる.
(defun coordinates (v) (get v 'coordinates))
(defun straight-distance (node-1 node-2)
(distance (coordinates node-1) (coordinates node-2)))
> (straight-distance 's 'd)
3.4641016151377544
> (straight-distance 's 'a)
4.358898943540674
という具合に求められる.
パスの長さは,
(defun path-length (path)
(if (null (rest path)) 0
(+ (straight-distance (first path) (second path))
(path-length (rest path)))))
と定義できる.
generated through LaTeX2HTML. M.Inaba 平成18年5月7日