[CM] newbie question: graph

Heinrich Taube taube at uiuc.edu
Tue Nov 23 05:47:00 PST 2010


> can somebody translate me this from 2.3.4-lisp to 3.7.0 cm-scheme?  
> (Just

(define x (make-graph `((a ,(make-weighting '(2 3)) 1)
                        (b ,(make-cycle '(1 3)) 2)
                        (c 1 3))
                      :for 20))
(next x #t)

-> (a c a b a b c a b a b c a c a b a c a c)

make-graph returns a graph pattern. graphs contain nodes, each node in  
a graph has an item
to return , a rule to move to the next node from that node, and a  
unique node identifier (id)
in the graph. rules return id's not items.

(<item>   <rule>   <id>)

when you specify a node i would recommend that you always provide all  
three values

> give me some non-trivial graph-examples in Scheme? Just as a starting
> point. I did not found any in the docs.

patterns are defined in cm.html, including graphs. select 'make-graph'  
with your mouse and hit COMMAND-D (Control-D on linux or win32)
there are lots of examples of patterns including graphs in :  
Help>Examples>Sal>Patterns 1    and Help>Examples>Sale>Patterns 2
if you already know Lisp then its trivial to read these examples in  
sal. additionally you can take a sal expression and convert it to  
scheme using the  Eval>Expand


On Nov 23, 2010, at 2:35 AM, Michael Winkler wrote:

> (setf x (new graph
>             (a to (new random b c))
>                (b to (new cycle a c))
>                (c to a) for 20))
> (next x t)



More information about the Cmdist mailing list