Sucessfully implemented Djikstra's algorithm

This commit is contained in:
2024-10-28 16:43:14 -05:00
parent bd704b2c66
commit 641048b56d
3 changed files with 74 additions and 15 deletions

20
test.scm Normal file
View File

@@ -0,0 +1,20 @@
(use-modules (rnrs base)
(d-)
(graphgif))
(begin
(display "Testing heap operations...")
(newline)
(let ([heap (~>> #()
(heap-insert (inf) 1)
(heap-insert (inf) 2)
(heap-insert (inf) 3)
(heap-insert 0 1))])
(assert (equal? (heap-peek heap) '(0 . 1)))
(set! heap (heap-insert 1 2 (heap-pop heap)))
(assert (equal? (heap-peek heap) '(1 . 2)))
(set! heap (heap-insert 3 3 heap))
(assert (equal? (heap-peek heap) '(1 . 2)))
(assert (equal? (heap-peek (heap-pop heap)) '(3 . 3))))
(assert (equal? (heap-pop #((0 . 0))) #()))
(assert (equal? (heap-peek (heap-pop (heap-pop #((1 . 1) (1 . 10) (+inf.0 . 2) (+inf.0 . 3) (1 . 11))))) '(1 . 11))))