X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fgraphviz.scm;h=ee3ddd7fe717072aa5cee8c420e790df6a018c8c;hb=fa8dd31ed29a5ef35d76f127a795b5c2d951f5dd;hp=f5db38b7a800a52d13f614411dc0707626784bee;hpb=e4b3aa8d0afa689a3a95e1c730cb3d2213418270;p=lilypond.git diff --git a/scm/graphviz.scm b/scm/graphviz.scm index f5db38b7a8..ee3ddd7fe7 100644 --- a/scm/graphviz.scm +++ b/scm/graphviz.scm @@ -1,26 +1,39 @@ -;;;; graphviz.scm -- utilities for creating graphviz output +;;;; This file is part of LilyPond, the GNU music typesetter. ;;;; -;;;; source file of the GNU LilyPond music typesetter +;;;; Copyright (C) 2007--2010 Joe Neeman ;;;; -;;;; (c) 2007 Joe Neeman +;;;; LilyPond is free software: you can redistribute it and/or modify +;;;; it under the terms of the GNU General Public License as published by +;;;; the Free Software Foundation, either version 3 of the License, or +;;;; (at your option) any later version. +;;;; +;;;; LilyPond is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;;; GNU General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU General Public License +;;;; along with LilyPond. If not, see . (define-module (scm graphviz) #:use-module (lily) #:export - (make-graph add-node add-edge add-cluster - graph-write - )) + (make-empty-graph add-node add-edge add-cluster + graph-write + )) -(define (make-graph filename) - #(() () () ())) +(define graph-type (make-record-type "graph" '(nodes edges clusters name))) +(define make-graph (record-constructor graph-type)) +(define (make-empty-graph name) (make-graph '() '() '() name)) -;; fixme: use structs/records. -;; fixme add & use setters. -(define (nodes g) (vector-ref g 1)) -(define (edges g) (vector-ref g 2)) -(define (clusters g) (vector-ref g 3)) +(define nodes (record-accessor graph-type 'nodes)) +(define edges (record-accessor graph-type 'edges)) +(define clusters (record-accessor graph-type 'clusters)) +(define set-nodes! (record-modifier graph-type 'nodes)) +(define set-edges! (record-modifier graph-type 'edges)) +(define set-clusters! (record-modifier graph-type 'clusters)) (define (add-cluster graph node-id cluster-name) (let* ((cs (clusters graph)) @@ -28,21 +41,21 @@ (already-in-cluster (if cluster (cdr cluster) '()))) - (vector-set! graph 3 (assq-set! cs + (set-clusters! graph (assq-set! cs cluster-name (cons node-id already-in-cluster))))) (define (add-node graph label . cluster-name) (let* ((ns (nodes graph)) (id (length ns))) - (vector-set! graph 1 (cons `(,id . ,label) ns)) + (set-nodes! graph (assq-set! ns id label)) (if (and (not (null? cluster-name)) (string? (car cluster-name))) (add-cluster graph id (car cluster-name))) id)) (define (add-edge graph node1 node2) - (vector-set! graph 2 (cons `(,node1 . ,node2) (edges graph)))) + (set-edges! graph (cons `(,node1 . ,node2) (edges graph)))) (define (graph-write graph out) (let ((ns (nodes graph))