unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#61527] [PATCH] Add edgelist graph backend
@ 2023-02-15  5:21 Kyle Andrews
  2023-02-15 16:32 ` Simon Tournier
  2023-02-27 22:48 ` Ludovic Courtès
  0 siblings, 2 replies; 7+ messages in thread
From: Kyle Andrews @ 2023-02-15  5:21 UTC (permalink / raw)
  To: 61527

[-- 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."

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-03-01 10:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-15  5:21 [bug#61527] [PATCH] Add edgelist graph backend Kyle Andrews
2023-02-15 16:32 ` 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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).