Hi Dmitry, > Ricardo Wurmus <rek...@elephly.net> writes: > > Could you provide examples of graph creation? It's not entirely obvious > to me how they need to be created via graph-cons. > > I tried doing something like this: > > (define test ;name > (graph-cons (context ; making context > "this-is-label" ;context label > (list (link "this-is-label-1" 1)) ;first link > (list (link "this-is-label-2" 1))) ;second link > graph-null)) ;initial graph > > This structure is created without problems, but when I want to draw it > through (draw test)
You can’t use (minigrad dot)’s “draw” because it’s not a generic graph drawing tool. It’s used for minigrad expressions, which have a certain structure. (Minigrad is supposed to be a testbed for neural nets with automatic backpropagation.) Here’s a simple example with a generic “draw” procedure to get you started:
graph-example.scm
Description: Binary data
As you can see every context links only to nodes that already exist in the graph. In the graph-cons example you see that node A cannot have any links to other nodes, because none exist. The edges between A and C and A and B are added later when the contexts of these nodes are cons’d onto the graph. That’s the big idea behind inductive graphs. To make the graphviz bindings work you need to set GUILE_EXTENSIONS_PATH first. I recommend this: $ guix shell graphviz guile $ [env] export GUILE_EXTENSIONS_PATH=$GUIX_ENVIRONMENT/lib/guile/3.0/extensions $ [env] guile --listen Then M-x connect-to-guile in a graphical Emacs and evaluate the code above to see the graph visualization. Hope this helps! -- Ricardo