Subject: [bug#61527] [PATCH] Add edgelist graph backend

From: Simon Tournier <[email-masked]>
Date: Wed, 15 Feb 2023 17:32:47 +0100

Hi,

On Wed, 15 Feb 2023 at 05:21, Kyle Andrews <[email-masked]> wrote:
> Dear Guix,
>
> I would like to be able to conveniently analyze Guix package
> dependencies using general purpose network analysis software such as
> igraph. To achieve this, I have added another backend to Guix and which
> is exposed via guix graph which spits out a three column table that,
> while not technically and edge list, is readily transformed into one
> with minimal data munging.

You might be interested by [1] where I export all the packages as
JSON-like (Python dictionary) and then import with python-networkx.

Feel free to report your analyses, I am very interested by such. :-)

1: https://yhetil.org/guix/[email-masked]

> +(define (emit-edgelist-prologue name port)
> +  (display "" port))

Here, I would add the description of the data as header of the CSV-like
file.  For instance, something:

--8<---------------cut here---------------start------------->8---
# type, name-or-edge1, item-or-edge2
# package, name, item
# depends, edge1, edge2
--8<---------------cut here---------------end--------------->8---

Well, is this format a standard format for representing graph?

>From igraph documentation [1], it reads ’igraph_read_graph_edgelist’:

        This format is simply a series of an even number of non-negative
        integers separated by whitespace. The integers represent vertex
        IDs. Placing each edge (i.e. pair of integers) on a separate
        line is not required, but it is recommended for
        readability. Edges of directed graphs are assumed to be in
        "from, to" order.

so maybe it could be nice to use this plain list for the edgelist
backend.  WDYT?

1: https://igraph.org/c/doc/igraph-Foreign.html#igraph_read_graph_edgelist

Cheers,
simon