Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save LeifAndersen/4fb357097a9687bcae536cc59cf3819a to your computer and use it in GitHub Desktop.
Save LeifAndersen/4fb357097a9687bcae536cc59cf3819a to your computer and use it in GitHub Desktop.
#lang editor/lang
(require (for-editor graph))
(define-editor tree$ pasteboard$
(super-new)
(define-state nodes (directed-graph '())
#:getter #t)
(define/public (add-root-node node [x 0] [y 0])
(send this add-child node x y)
(add-vertex! nodes node))
(define/public (add-child-node parent node [x 0] [y 0])
(add-root-node node x y)
(add-directed-edge! nodes parent node)))
(begin-for-editor
(define tree (new tree$))
(define root (new label$ [text "HI"] [persistence #t]))
(send tree add-root-node root)
(send tree add-child-node root (new label$ [text "WORLD"] [persistence #t]) 25 50)
tree
;(get-vertices (send tree get-nodes))
(displayln (graphviz (send tree get-nodes))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment