Gauche-graphviz is a Gauche module that provides function reading/writing Graphviz dot language.

Download: Gauche-graphviz-1.0.2.tgz (2019-8-6)


How to use

;; -*- coding: utf-8-unix -*-

(use graphviz)

;;; Load exists graphviz dot file and convert into sdot structure.
;;; And extract all edge object from sdot structure.
(let ((sdot (parse-graphviz-dot-file "./generic_programing.dot")))
  (find-sdot-object (^x (eq? (get-sdot-type x) 'edge-stmt)) sdot))

;;; Extract all nodes and edges object from sdot structure.
;;; Append attribute 'color' to each edge object and
;;; attribute 'fillcolor' and 'style' to each node object.
(let ((sdot (parse-graphviz-dot-file "./generic_programing.dot"))
      (edges '())
      (nodes '()))
  (set! edges (find-sdot-object (^x (eq? (get-sdot-type x) 'edge-stmt)) sdot))
  (set! nodes (find-sdot-object (^x (eq? (get-sdot-type x) 'node-stmt)) sdot))
  (dolist (edge edges)
    (add-sdot-attr! edge '("color" "cyan")))
  (dolist (node nodes)
    (add-sdot-attr! node '("fillcolor" "pink") '("style" "filled")))
  (call-with-output-file "generic_programing2.dot"
    (^(out) (sdot->graphviz-dot sdot out)))
  (graphviz-dot->x "generic_programing2.dot" "png" "generic_programing2.png"))