Gnp -> gnp; Gnm -> gnm, etc for mlisp happiness
[cl-graph.git] / dev / graphviz / graphviz-support.lisp
index 4b3bbd3..26a35bf 100644 (file)
@@ -87,9 +87,11 @@ This file contains the stuff that does not depend on cl-graphviz.
         (iterate-vertexes 
          g
          (lambda (v)
+          ;(spy v)
            (iterate-edges
             v
             (lambda (e)
+             ;(spy e (undirected-edge-p e) (item-at-1 edges e))
               (when (and (undirected-edge-p e)
                          (not (item-at-1 edges e)))
                 (setf (item-at-1 edges e) t)
@@ -243,7 +245,7 @@ B--D []
 |#
 
 (defparameter *dot-graph-attributes*
-  '((:size coord)
+  '((:size coordinate)
     (:bb bounding-box)
     (:page text)
     (:ratio (:fill :compress :auto)) ;; Could actually be a float number too
@@ -273,10 +275,12 @@ B--D []
              :doublecircle))
     (:fontsize integer)
     (:fontname text)
+    (:fontcolor text)
     (:color text)
     (:fillcolor text)
     (:style (:filled :solid :dashed :dotted :bold :invis))
-    (:layer text)))
+    (:layer text)
+    (:url text)))
 
 (defparameter *dot-edge-attributes*
   '((:pos spline)
@@ -315,7 +319,11 @@ B--D []
   (:export-p t))
 
 (defclass* dot-graph-mixin (dot-attributes-mixin) ()
-  (:export-p t))
+  (:export-p t)
+  (:default-initargs
+    :vertex-class 'dot-vertex
+    :directed-edge-class 'dot-directed-edge
+    :undirected-edge-class 'dot-edge))
 (defclass* dot-vertex-mixin (dot-attributes-mixin) ()
   (:export-p t))
 (defclass* dot-edge-mixin (dot-attributes-mixin) ()
@@ -323,10 +331,6 @@ B--D []
 
 (defclass* dot-graph (dot-graph-mixin graph-container)
   ()
-  (:default-initargs
-    :vertex-class 'dot-vertex
-    :directed-edge-class 'dot-directed-edge
-    :undirected-edge-class 'dot-edge)
   (:export-p t))
 
 (defclass* dot-vertex (dot-vertex-mixin graph-container-vertex) ()
@@ -338,6 +342,7 @@ B--D []
 
 
 (defmethod (setf dot-attribute-value) :before (value (attr symbol) (thing dot-attributes-mixin))
+  (declare (ignore value))
   (ensure-valid-dot-attribute attr thing))
 
 (defmethod (setf dot-attribute-value) (value (attr symbol) (thing dot-attributes-mixin))
@@ -349,8 +354,7 @@ B--D []
 (defmethod graph->dot-properties ((graph dot-graph-mixin) (stream t))
   (loop for (name value) on (dot-attributes graph) by #'cddr
         do
-        (print-dot-key-value name value *dot-graph-attributes* stream)
-        (format stream "                 ;~%")))
+        (print-dot-key-value name value *dot-graph-attributes* stream)))
 
 (defmethod vertex->dot ((vertex dot-vertex-mixin) (stream t))
   (format-dot-attributes vertex *dot-vertex-attributes* stream))
@@ -380,7 +384,8 @@ B--D []
   (destructuring-bind (key value-type)
       (or (assoc key dot-attributes)
           (error "Invalid attribute ~S" key))
-    (format stream "~a=~a" (string-downcase key)
+    (write-name-for-dot key stream)
+    (format stream "=~a" 
             (etypecase value-type
               ((member coordinate)
                (with-output-to-string (str)
@@ -437,6 +442,12 @@ B--D []
                    (string-downcase value)
                    value))))))
 
+(defmethod write-name-for-dot (attribute stream)
+  (format stream "~(~A~)" attribute))
+
+(defmethod write-name-for-dot ((attribute (eql :url)) stream)
+  (format stream "URL"))
+
 (defun textify (object)
   (let ((string (princ-to-string object)))
     (with-output-to-string (stream)