ryoakg
4/7/2016 - 2:28 PM

dorothy_example.clj

;;; `boot repl` to go
(set-env! :dependencies '[[dorothy "0.0.6"]])
(require '[dorothy.core :refer :all])

;;; via http://qiita.com/kurogelee/items/aa5bb531ff87de0fe99e

(-> [;; nodes
     :node1
     :node2

     ;; connections
     [:node1 :node2]]
    graph dot show!)

;;; only connections
(-> [[:a :b :c :d :a]]
    digraph dot show!)

;;; node with attributes.
(-> [[:node1 {:style :filled :shape :record}]]
    digraph dot show!)

;;; non-directed graph
(-> [[:a :b :c :d :a {:arrowhead :empty}]]
    digraph dot show!)

;;; graph attribute
(-> [(node-attrs {:color :red})
     (edge-attrs {:style :dashed})
     [:node1 {:style :filled :shape :record}] :node2
     [:a :b :c :d :a {:arrowhead :empty}]
     [:e :f]]
    digraph dot show!)

;;; write to a file.
(-> [(node-attrs {:color :red})
     (edge-attrs {:style :dashed})
     [:node1 {:style :filled :shape :record}] :node2
     [:a :b :c :d :a {:arrowhead :empty}]
     [:e :f]]
    digraph dot (save! "out.png" {:format :png}))