More cleanup, fix things broken in last cleanup
This commit is contained in:
parent
f4b52415dc
commit
3eb52aa430
12
demo.scm
12
demo.scm
@ -18,18 +18,14 @@
|
|||||||
(set-node-color (cdr pair) red)
|
(set-node-color (cdr pair) red)
|
||||||
(cdr pair))))
|
(cdr pair))))
|
||||||
graph))
|
graph))
|
||||||
|
(define (make-graph-generator f)
|
||||||
(define djikstra-generator
|
|
||||||
(generator
|
(generator
|
||||||
(djikstra graph 90 9 (lambda (visited heap)
|
(f graph 90 9 (lambda (visited heap)
|
||||||
(yield (color-graph graph visited heap))))
|
(yield (color-graph graph visited heap))))
|
||||||
#f))
|
#f))
|
||||||
(define a*-generator
|
|
||||||
(generator
|
|
||||||
(a* graph 90 9 (lambda (visited heap)
|
|
||||||
(yield (color-graph graph visited heap))))
|
|
||||||
#f))
|
|
||||||
|
|
||||||
|
(define djikstra-generator (make-graph-generator djikstra))
|
||||||
|
(define a*-generator (make-graph-generator a*))
|
||||||
(write-graphs-to-file "djikstra.webp" djikstra-generator)
|
(write-graphs-to-file "djikstra.webp" djikstra-generator)
|
||||||
(write-graphs-to-file "astar.webp" a*-generator)
|
(write-graphs-to-file "astar.webp" a*-generator)
|
||||||
|
|
||||||
|
@ -33,12 +33,11 @@
|
|||||||
(lambda (node)
|
(lambda (node)
|
||||||
(cairo-set-source cr black)
|
(cairo-set-source cr black)
|
||||||
(let-values ([(x y) (car+cdr (node-coords node))]
|
(let-values ([(x y) (car+cdr (node-coords node))]
|
||||||
[edges (node-edges node)])
|
[(edges) (node-edges node)])
|
||||||
(for-each
|
(for-each
|
||||||
(lambda (edge)
|
(lambda (edge)
|
||||||
(let* ([other (assq-ref graph edge)]
|
(let*-values ([(other) (assq-ref graph edge)]
|
||||||
[ox (car (node-coords other))]
|
[(ox oy) (car+cdr (node-coords other))])
|
||||||
[oy (cdr (node-coords other))])
|
|
||||||
(cairo-move-to cr x y)
|
(cairo-move-to cr x y)
|
||||||
(cairo-line-to cr ox oy)
|
(cairo-line-to cr ox oy)
|
||||||
(cairo-stroke cr)))
|
(cairo-stroke cr)))
|
||||||
@ -48,7 +47,7 @@
|
|||||||
"Creates a closure that draws the nodes of graph using cr"
|
"Creates a closure that draws the nodes of graph using cr"
|
||||||
(lambda (node)
|
(lambda (node)
|
||||||
(let-values ([(x y) (car+cdr (node-coords node))]
|
(let-values ([(x y) (car+cdr (node-coords node))]
|
||||||
[color (or (node-color node) white)])
|
[(color) (or (node-color node) white)])
|
||||||
(cairo-arc cr x y 4. 0. tau)
|
(cairo-arc cr x y 4. 0. tau)
|
||||||
(cairo-set-source cr color)
|
(cairo-set-source cr color)
|
||||||
(cairo-fill-preserve cr)
|
(cairo-fill-preserve cr)
|
||||||
|
Loading…
Reference in New Issue
Block a user