diff --git a/hsmusic.lisp b/hsmusic.lisp index 1cfdca7..d194a2d 100644 --- a/hsmusic.lisp +++ b/hsmusic.lisp @@ -1,6 +1,6 @@ -(ql:quickload '(:cl-yaml :alexandria :cl-graph :cl-ppcre)) +(ql:quickload '(:cl-yaml :alexandria :cl-ppcre)) (defpackage :hsmusic - (:use :common-lisp :alexandria :cl-graph)) + (:use :common-lisp :alexandria)) (in-package :hsmusic) (defparameter tracks @@ -17,22 +17,14 @@ (sb-unicode:normalize-string (string-downcase name) :nfkd) "")) -(defparameter graph (containers:make-container 'graph-container :default-edge-type :directed)) +(defun track-normalized-name (track) + (normalize-name (gethash "Track" track))) + +(defparameter edges (make-hash-table :test 'equal)) +; (from . to) +; conceptually, from -> to (loop for track in tracks - do - (loop for ref in (append (gethash "Referenced Tracks" track) (gethash "Sampled Tracks" track)) - do (format t "~a -> ~a~%" (normalize-name (gethash "Track" track)) (normalize-name ref)) - do (add-edge-between-vertexes - graph - (normalize-name (gethash "Track" track)) - (normalize-name ref)))) - -(defun track-vertex (name) - (find-vertex-if graph (lambda (x) (equal (slot-value x 'element) (normalize-name name))))) - -; instead of this whole graph thing, i *could* do an alist -; rassoc exists -; BUT the graph library has :o algorithms :o -; BUT still would be faster than 1st attempt - + do (let ((name (track-normalized-name track))) + (loop for ref in (append (gethash "Referenced Tracks" track) (gethash "Sampled Tracks" track)) + do (setf (gethash (cons (normalize-name ref) name) edges) t))))