Use records instead of conss for nodes, alist for graphs

This commit is contained in:
2024-10-21 14:05:11 -05:00
parent 6d6d1eec18
commit a3f0ee2eb9
2 changed files with 38 additions and 35 deletions

View File

@@ -1,19 +1,10 @@
(use-modules (graphgif))
(use-modules (graphgif)
(srfi srfi-9 gnu)
(ice-9 copy-tree))
(define red (create-color 1 0 0))
(define my-graph
`(((10 . 10) (1))
((30 . 20) () ,red)))
(define more-complex-graph
`(((10 . 10) ())
((40 . 10) (0))
((25 . 25) (0 1))
((10 . 40) (0 2 4))
((40 . 40) (1 2 3))))
(let* ([graph1 (generate-web 10 10)]
[graph2 (list-copy graph1)])
(set-car! graph2 (append (car graph2) `(,red)))
(write-graphs-to-file (list graph1 graph2) "graph.gif"))
(define graph1 (generate-web 10 10))
(define graph2 (copy-tree graph1))
(assq-set! graph2 0 (set-node-color (assq-ref graph2 0) red))
(write-graphs-to-file (list graph1 graph2) "graph.gif")