Skip to content
Library to enable using graphviz in Racket programs
Racket
Branch: master
Clone or download
Latest commit 7eea629 Aug 12, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples ER Diagram example. Aug 4, 2019
images Cache doc images Aug 11, 2019
lib Add contracts Aug 9, 2019
scribblings add some debugging Aug 12, 2019
.gitignore clean-up package metadata. Aug 3, 2019
LICENSE Initial commit Jul 20, 2019
README.md Update README.md Aug 4, 2019
example.rkt Make dirtree a commandline program Aug 3, 2019
info.rkt add (digraph? ...) to docs Aug 9, 2019
main.rkt update main.rkt Aug 4, 2019

README.md

Racket GraphViz Integration

The goal of this library is to make composition of Racket Pict and Graphviz Diagrams possible.

The composition is made possible through:

  • You can use graphviz diagrams as normal picts
  • You can use any Pict as node shape of graphviz diagrams

For example, in the following program note that the shapes for nodes "c" and "f" and also the node with fish shape are racket shapes. Rest of the nodes use a shape provided by graphviz.

(digraph->pict
 (make-digraph
  `(["a" #:shape "diamond" #:fillcolor "lightgray" #:style "filled"]
    ["b" #:shape ,(cloud 60 30) #:label "c"]
    ["c" #:shape ,(standard-fish 100 50 #:open-mouth #t #:color "Chartreuse")
         #:label ""]
    "d"
    "a -> b -> c"
    "a -> d -> c"
    (subgraph "stdout" #:style "filled" #:fillcolor "cyan"
              (["f" #:shape ,(file-icon 50 60 "bisque")]
               "g"
               "f -> g"))
    "d -> g")))

As another example, take a look at dirtree.rkt which dynamically generates a directory tree.

Notice how dirtree.rkt has used make-vertex and make-edge functions:

...
(define root (make-vertex (path->string name) #:shape shape))
...
(make-edge root-node sub-node)
...

You can pass a list of vertex and edges to make-digraph to create a digraph, and use digraph->pict to convert it to a pict.

(define d (make-digraph (list v1 v2 (make-edge v1 v2))))
(digraph->pict d)
You can’t perform that action at this time.