[cl-graph-devel] cl-graph symbol it has no value

Gary King gwking at metabang.com
Tue Jun 10 04:17:04 UTC 2008


Hi Andrej,

> thanx for programming this huge package.

I hope it serves you well.

> tried running the code:
>
> (let ((g (make-container 'graph-container)))
>   (loop for v in '(a b c d e) do
>         (add-vertex g v))
>   (loop for (v1 . v2) in '((a . b) (a . c) (b . d) (c . e)) do
>         (add-edge-between-vertexes g v1 v2))
>   g)
>
> and got this:
>
> #1=#:|616 623 (DEFMETHOD FIND-VERTEX (# #  
> &OPTIONAL ...) ...)-62-1-1|: symbol IT has no value
>    [Condition of type SYSTEM::SIMPLE-UNBOUND-VARIABLE
> ]

The problem is caused by my recent reorganization. aif (and awhen and  
a...) are called "anaphoric" macros which just means that they  
introduce a pronoun that you can use to refer to some useful bit of  
computation. If you see

(aif (foo)
   it (bar))

just think

(let ((it (foo)))
   (if it it (bar)))

Here is the definition

(defmacro aif (test-form then-form &optional else-form (pred nil predp))
   "Anaphoric IF:  Binds the symbol `it' to the value of the `test.'"
   `(let ((it ,test-form))
      (if ,(if predp `(funcall ,pred it) 'it)
        ,then-form ,else-form)))

metatilities has a bunch of anaphoric macros in it as does the  
anaphora system on http://common-lisp.net/. In this case, the aif  
macro wasn't visible so the code in find-vertex broke.

> Second question is about a use-case
>
> can I make a directed graph with the following structure and how?
>
> A D
> B D
> C D
> D E
> G E
> E F
> E J
> J H

Yes. Something like

(let ((g (make-container 'graph-container)))
   (loop for (v1  v2) in '((A D)
			  (B D)
			  (C D)
			  (D E)
			  (G E)
			  (E F)
			  (E J)
			  (J H)) do
        (add-edge-between-vertexes g v1 v2))
   g)

will work fine (once the anaphoric problem is fixed).


> Is the cl-graph package only for exporting the graphs to dot format,  
> or can you do more stuff with the graphs? Where can I find more  
> tutorials? (the one on uncommon wiki was not suitable for my simple  
> use case). Can you use a graph as a data-structure ? Can you  
> traverse and search the directed graph? A simple (even uncommented)  
> tutorial would be much appreciated.

CL-Graph wants to be a general purpose graph manipulation library.  
Exporting to dot is only the start. That said, it still has much  
growing to do before the C++ BOOST library will need to feel  
threatened! There is code to compute some metrics, to do search, to  
handle some basic algorithms, etc. I doubt I'll have time to write a  
tutorial but I will try to clean up and organize the (non-existent)  
documentation sometime this week.

Tomorrow I will post a patch for the problems you encountered. If you  
have specific requests or needs, please let me know.

> Thanks a lot, happy coding

thanks, you too!
--
Gary Warren King, metabang.com
Cell: (413) 559 8738
Fax: (206) 338-4052
gwkkwg on Skype * garethsan on AIM







More information about the cl-graph-devel mailing list