Dijkstra's algorithm: Difference between revisions
Content added Content deleted
Line 1,363: | Line 1,363: | ||
(defun paths (c g z v) |
(defun paths (c g z v) |
||
(if (eql c g) (push `(,(reverse v) ,z) *r*) |
(if (eql c g) (push `(,(reverse v) ,z) *r*) |
||
(loop for a in (nodes c) do |
(loop for a in (nodes c) for b = (cadr a) do |
||
(unless (member |
(unless (member b v) |
||
(paths |
(paths b g (+ (cddr a) z) (cons b v)))))) |
||
(cons (cadr a) v)))))) |
|||
(defun nodes (c) |
(defun nodes (c) |
||
Line 1,395: | Line 1,394: | ||
(defun paths (w c g z v) |
(defun paths (w c g z v) |
||
(if (eql c g) (push `(,(reverse v) ,z) *r*) |
(if (eql c g) (push `(,(reverse v) ,z) *r*) |
||
(loop for a in (nodes c w) do |
(loop for a in (nodes c w) for b = (cadr a) do |
||
(unless (member |
(unless (member b v) |
||
(paths w |
(paths w b g (+ (cddr a) z) (cons b v)))))) |
||
(cons (cadr a) v)))))) |
|||
(defun nodes (c w) |
(defun nodes (c w) |