Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,18 @@
(de neighbor (X Y Cost)
(push (prop X 'neighbors) (cons Y Cost))
(push (prop Y 'neighbors) (cons X Cost)) )
(de dijkstra (Curr Dest)
(let Cost 0
(until (== Curr Dest)
(let (Min T Next)
(for N (; Curr neighbors)
(with (car N)
(let D (+ Cost (cdr N))
(unless (and (: distance) (>= D @))
(=: distance D) ) )
(when (> Min (: distance))
(setq Min (: distance) Next This) )
(del (asoq Curr (: neighbors)) (:: neighbors)) ) )
(setq Curr Next Cost Min) ) )
Cost ) )

View file

@ -0,0 +1,11 @@
(neighbor 'a 'b 7)
(neighbor 'a 'c 9)
(neighbor 'a 'f 14)
(neighbor 'b 'c 10)
(neighbor 'b 'd 15)
(neighbor 'c 'd 11)
(neighbor 'c 'f 2)
(neighbor 'd 'e 6)
(neighbor 'e 'f 9)
(dijkstra 'a 'e)