[cl-graph-devel] Graphing package usage.
Ben Hyde
bhyde at pobox.com
Thu Dec 1 04:15:23 UTC 2005
Something to thread the needle in the mailing list. - ben
(defpackage "FOO"
(:use "COMMON-LISP"
"CL-PPCRE" ;; For regular expressions.
"CL-GRAPH"))
(in-package "FOO")
(defun foo (dot-file)
"Generate a graphviz illustration of package topology."
(flet ((ignore-package (p)
(cl-ppcre:scan "^ASDF\\d+$" (package-name p))))
(loop
with graph = (make-graph 'graph-container
:default-edge-type :directed)
finally
(flet ((graph-formatter (graph s)
(declare (ignore graph))
(format s ;; ok ok, this is too foxy.
"concentrate=true] node [shape=plaintext]; edge
[arrowhead=open")))
(graph->dot graph dot-file
:graph-formatter #'graph-formatter
:vertex-key #'(lambda (v) (vertex-id v))
:vertex-labeler
#'(lambda (v s)
(princ (package-name (element v)) s))))
for upper-package in (list-all-packages)
unless (ignore-package upper-package)
do (loop for lower-package in (package-use-list upper-package)
unless (ignore-package lower-package)
do (add-edge-between-vertexes
graph lower-package upper-package)))))
More information about the cl-graph-devel
mailing list