all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kyle Andrews <kyle@posteo.net>
To: 61527@debbugs.gnu.org
Subject: [bug#61527] [PATCH] Add edgelist graph backend
Date: Wed, 15 Feb 2023 05:21:35 +0000	[thread overview]
Message-ID: <875yc3sdfo.fsf@posteo.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 538 bytes --]


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.

Please see the attached patch file which I have created with `git diff'
from my working tree since I am not yet comfortable with more advanced
git workflows.

[-- Attachment #2: edgelist backend patch --]
[-- Type: text/plain, Size: 1150 bytes --]

diff --git a/guix/graph.scm b/guix/graph.scm
index 41219ab67d..e1760ed92a 100644
--- a/guix/graph.scm
+++ b/guix/graph.scm
@@ -255,6 +255,24 @@ (define %graphviz-backend
                  emit-prologue emit-epilogue
                  emit-node emit-edge))
 
+(define (emit-edgelist-prologue name port)
+  (display "" port))
+
+(define (emit-edgelist-epilogue port)
+  (display "" port))
+
+(define (emit-edgelist-node id label port)
+  (format port "package, ~a, ~a\n" label id))
+
+(define (emit-edgelist-edge id1 id2 port)
+  (format port "depends, ~a, ~a\n" id1 id2))
+
+(define %edgelist-backend
+  (graph-backend "edgelist"
+                 "Generate graph in CSV edge list format"
+                 emit-edgelist-prologue emit-edgelist-epilogue
+                 emit-edgelist-node emit-edgelist-edge))
+
 \f
 ;;;
 ;;; d3js export.
@@ -338,7 +356,8 @@ (define %cypher-backend
 (define %graph-backends
   (list %graphviz-backend
         %d3js-backend
-        %cypher-backend))
+        %cypher-backend
+        %edgelist-backend))
 
 (define (lookup-backend name)
   "Return the graph backend called NAME.  Raise an error if it is not found."

             reply	other threads:[~2023-02-15  5:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-15  5:21 Kyle Andrews [this message]
2023-02-15 16:32 ` [bug#61527] [PATCH] Add edgelist graph backend Simon Tournier
2023-02-16  3:28   ` Kyle Andrews
2023-02-27 22:48 ` Ludovic Courtès
2023-02-28  9:21   ` Simon Tournier
2023-03-01  3:49     ` Kyle Andrews
2023-03-01 10:34       ` Simon Tournier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875yc3sdfo.fsf@posteo.net \
    --to=kyle@posteo.net \
    --cc=61527@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.