Created
May 20, 2019 16:07
-
-
Save LeifAndersen/4fb357097a9687bcae536cc59cf3819a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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