(setq *graph1-with-cost* '((a s 5.0) (b a 3.0) (c b 4.0) (d a 6.0827627) (d s 4.2426405) (e d 3.0) (e b 6.0827627) (f e 5.8309517))) (defun init-graph-cost (ee) (mapc #'(lambda (e) (put (elt e 0) (elt e 1) (elt e 2)) (put (elt e 1) (elt e 0) (elt e 2))) ee)) (defun node-distance (n1 n2) (get n1 n2))というぐあいに,辺間の距離をリストにしたデータから 頂点の属性として,属性を隣接する頂点の名前とし,値を距離に するという具合に定義しています.
> (init-graph-cost *graph1-with-cost*) ((a s 5.0) (b a 3.0) (c b 4.0) (d a 6.0827627) (d s 4.2426405) (e d 3.0) (e b 6.0827627) (f e 5.8309517)) > (get 'a 's) 5.0 > (get 's 'a) 5.0 > (get 's 'b) nil > (node-distance 'd 's) 4.2426405 > (node-distance 's 'd) 4.2426405node-distanceは2つの頂点を与えるとその頂点間の距離を返します.