2024-10-21 14:05:11 -05:00
|
|
|
(use-modules (graphgif)
|
2024-10-28 16:43:14 -05:00
|
|
|
(srfi srfi-1)
|
|
|
|
(srfi srfi-43)
|
2024-10-23 09:13:50 -05:00
|
|
|
(ice-9 copy-tree)
|
|
|
|
(d-))
|
2024-10-11 16:48:42 -05:00
|
|
|
|
2024-10-16 13:48:22 -05:00
|
|
|
(define red (create-color 1 0 0))
|
|
|
|
|
2024-10-28 16:43:14 -05:00
|
|
|
(define graph
|
|
|
|
(~> (generate-web 10 10)
|
2024-10-23 09:46:15 -05:00
|
|
|
(remove-rect 10 1 3 6 3)
|
|
|
|
(remove-rect 10 6 3 6 7)))
|
2024-10-28 16:43:14 -05:00
|
|
|
|
|
|
|
(define (color-graph graph visited heap)
|
|
|
|
(map (lambda (pair)
|
|
|
|
(cons (car pair)
|
|
|
|
(if (memq (car pair) visited)
|
|
|
|
(set-node-color (cdr pair) red)
|
|
|
|
(cdr pair))))
|
|
|
|
graph))
|
|
|
|
|
2024-11-11 21:07:19 -06:00
|
|
|
(define djikstra-generator
|
2024-10-29 12:01:56 -05:00
|
|
|
(make-generator
|
|
|
|
(lambda (yield)
|
|
|
|
(djikstra graph 90 9 (lambda (visited heap)
|
|
|
|
(yield (color-graph graph visited heap))))
|
|
|
|
#f)))
|
2024-11-11 21:07:19 -06:00
|
|
|
(define a*-generator
|
|
|
|
(make-generator
|
|
|
|
(lambda (yield)
|
|
|
|
(a* graph 90 9 (lambda (visited heap)
|
|
|
|
(yield (color-graph graph visited heap))))
|
|
|
|
#f)))
|
|
|
|
(write-graphs-to-file "djikstra.webp" djikstra-generator)
|
|
|
|
(write-graphs-to-file "astar.webp" a*-generator)
|
2024-10-28 16:43:14 -05:00
|
|
|
|