This file is indexed.

/usr/share/lilypond/2.18.2/scm/graphviz.scm is in lilypond-data 2.18.2-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
;;;; This file is part of LilyPond, the GNU music typesetter.
;;;;
;;;; Copyright (C) 2007--2012 Joe Neeman <joeneeman@gmail.com>
;;;;
;;;; 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 <http://www.gnu.org/licenses/>.


(define-module (scm graphviz)
  #:use-module (lily)
  #:export
  (make-empty-graph add-node add-edge add-cluster
                    graph-write
                    ))

(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))

(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))
         (cluster (assoc cluster-name cs))
         (already-in-cluster (if cluster
                                 (cdr cluster)
                                 '())))
    (set-clusters! graph (assoc-set! cs
                                     cluster-name
                                     (cons node-id already-in-cluster)))))

(define (add-node graph label . cluster-name)
  (let* ((ns (nodes graph))
         (id (length ns)))
    (set-nodes! graph (assv-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)
  (set-edges! graph (cons `(,node1 . ,node2) (edges graph))))

(define (graph-write graph out)
  (let ((ns (nodes graph))
        (es (edges graph))
        (cs (clusters graph)))
    (ly:message (format #f (_ "Writing graph `~a'...") (port-filename out)))
    (display "digraph G {\nrankdir=\"LR\"\nnode [shape=rectangle]\n" out)
    (for-each (lambda (n) (format out "~a [label=\"~a\"]\n" (car n) (cdr n)))
              ns)
    (for-each (lambda (e) (format out "~a -> ~a\n" (car e) (cdr e)))
              es)
    (for-each (lambda (c)
                (format out "subgraph cluster_~a {\nlabel= \"~a\"\ncolor=blue\n"
                        (string-filter (car c) char-alphabetic?)
                        (car c))
                (for-each (lambda (n) (format out "~a\n" n)) (cdr c))
                (display "}\n" out))
              cs)
    (display "}" out)))