GNU bug report logs - #61888
[PATCH] guix: add edgelist graph-backend.

Previous Next

Package: guix-patches;

Reported by: kyle <kyle <at> posteo.net>

Date: Wed, 1 Mar 2023 03:49:02 UTC

Severity: normal

Tags: patch

Merged with 61527

To reply to this bug, email your comments to 61888 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#61888; Package guix-patches. (Wed, 01 Mar 2023 03:49:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to kyle <kyle <at> posteo.net>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Wed, 01 Mar 2023 03:49:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: kyle <kyle <at> posteo.net>
To: guix-patches <at> gnu.org
Cc: Kyle Andrews <kyle <at> posteo.net>
Subject: [PATCH] guix: add edgelist graph-backend.
Date: Wed, 01 Mar 2023 03:48:35 +0000
From: Kyle Andrews <kyle <at> posteo.net>

* guix/graph.scm: Add csv backend.
---
 doc/guix.texi  | 14 ++++++++------
 guix/graph.scm | 21 ++++++++++++++++++++-
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 27a0c62532..09d6be4edb 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -14844,16 +14844,18 @@ Invoking guix graph
 Packages and their dependencies form a @dfn{graph}, specifically a
 directed acyclic graph (DAG).  It can quickly become difficult to have a
 mental model of the package DAG, so the @command{guix graph} command
-provides a visual representation of the DAG@.  By default,
-@command{guix graph} emits a DAG representation in the input format of
+provides a visual representation of the DAG@.  By default, @command{guix
+graph} emits a DAG representation in the input format of
 @uref{https://www.graphviz.org/, Graphviz}, so its output can be passed
 directly to the @command{dot} command of Graphviz.  It can also emit an
 HTML page with embedded JavaScript code to display a ``chord diagram''
 in a Web browser, using the @uref{https://d3js.org/, d3.js} library, or
 emit Cypher queries to construct a graph in a graph database supporting
-the @uref{https://www.opencypher.org/, openCypher} query language.  With
-@option{--path}, it simply displays the shortest path between two
-packages.  The general syntax is:
+the @uref{https://www.opencypher.org/, openCypher} query language.  It
+can also emit a CSV table with the raw data required to reconstruct the
+graph using generic network analysis software like
+@uref{https://igraph.org/, igraph}. With @option{--path}, it simply
+displays the shortest path between two packages.  The general syntax is:
 
 @example
 guix graph @var{options} @var{package}@dots{}
@@ -15061,7 +15063,7 @@ Invoking guix graph
 @item --list-backends
 List the supported graph backends.
 
-Currently, the available backends are Graphviz and d3.js.
+Currently, the available backends are Graphviz, Cypher, d3.js, and csv.
 
 @item --path
 Display the shortest path between two nodes of the type specified by
diff --git a/guix/graph.scm b/guix/graph.scm
index 41219ab67d..6a3f802da9 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-csv-prologue name port)
+  (display "table, from, to\n" port))
+
+(define (emit-csv-epilogue port)
+  (display "" port))
+
+(define (emit-csv-node id label port)
+  (format port "package, ~a, ~a\n" label id))
+
+(define (emit-csv-edge id1 id2 port)
+  (format port "depends, ~a, ~a\n" id1 id2))
+
+(define %csv-backend
+  (graph-backend "csv"
+                 "Generate graph in CSV format"
+                 emit-csv-prologue emit-csv-epilogue
+                 emit-csv-node emit-csv-edge))
+
 
 ;;;
 ;;; d3js export.
@@ -338,7 +356,8 @@ (define %cypher-backend
 (define %graph-backends
   (list %graphviz-backend
         %d3js-backend
-        %cypher-backend))
+        %cypher-backend
+        %csv-backend))
 
 (define (lookup-backend name)
   "Return the graph backend called NAME.  Raise an error if it is not found."
-- 
2.37.2





Merged 61527 61888. Request was from Liliana Marie Prikler <liliana.prikler <at> ist.tugraz.at> to control <at> debbugs.gnu.org. (Wed, 01 Mar 2023 09:33:02 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 111 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.