graphgif/demo.scm

27 lines
694 B
Scheme
Raw Permalink Normal View History

(use-modules (graphgif)
2024-10-23 09:13:50 -05:00
(d-))
(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)))
(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))
(define (make-graph-generator f)
2024-11-11 22:15:04 -06:00
(generator
2024-11-19 12:01:07 -06:00
(f graph 90 9
(lambda (visited heap)
(yield (color-graph graph visited heap))))
2024-11-11 22:15:04 -06:00
#f))
(define djikstra-generator (make-graph-generator djikstra))
(define a*-generator (make-graph-generator a*))
2024-11-11 21:07:19 -06:00
(write-graphs-to-file "djikstra.webp" djikstra-generator)
(write-graphs-to-file "astar.webp" a*-generator)