[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Looking for graph library
From: |
Ricardo Wurmus |
Subject: |
Re: Looking for graph library |
Date: |
Wed, 12 Oct 2022 18:33:22 +0200 |
User-agent: |
mu4e 1.8.9; emacs 28.1 |
Hi Dmitry,
> Ricardo Wurmus <rekado@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
- Looking for graph library, Dmitry Polyakov, 2022/10/08
- Re: Looking for graph library, Maxime Devos, 2022/10/08
- Re: Looking for graph library, Ricardo Wurmus, 2022/10/08
- Re: Looking for graph library, David Pirotte, 2022/10/08
- Re: Looking for graph library, Ricardo Wurmus, 2022/10/09
- Re: Looking for graph library, David Pirotte, 2022/10/09
- Re: Looking for graph library, Ricardo Wurmus, 2022/10/09
- Re: Looking for graph library, Dmitry Polyakov, 2022/10/12
- Re: Looking for graph library,
Ricardo Wurmus <=
- Re: Looking for graph library, Dmitry Polyakov, 2022/10/12
- Re: Looking for graph library, zimoun, 2022/10/14