unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* bug#26807: [PATCH] graph: Add Cypher backend.
@ 2017-05-06 21:21 Roel Janssen
  2017-05-10 20:59 ` Ludovic Courtès
  0 siblings, 1 reply; 6+ messages in thread
From: Roel Janssen @ 2017-05-06 21:21 UTC (permalink / raw)
  To: 26807

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-graph-Add-Cypher-backend.patch --]
[-- Type: text/x-patch, Size: 1702 bytes --]

From 0e9c95ef3473fa7066ccd5991b1c14400aaa7076 Mon Sep 17 00:00:00 2001
From: Roel Janssen <roel@gnu.org>
Date: Sat, 6 May 2017 23:15:03 +0200
Subject: [PATCH] graph: Add Cypher backend.

* guix/graph.scm (%cypher-backend): New variable.
---
 guix/graph.scm | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/guix/graph.scm b/guix/graph.scm
index 7af2cd3b8..d7fd5f3e4 100644
--- a/guix/graph.scm
+++ b/guix/graph.scm
@@ -229,6 +229,35 @@ nodeArray.push(nodes[\"~a\"]);~%"
                  emit-d3js-prologue emit-d3js-epilogue
                  emit-d3js-node emit-d3js-edge))
 
+
+\f
+;;;
+;;; Cypher export.
+;;;
+
+(define (emit-cypher-prologue name port)
+  (format port ""))
+
+(define (emit-cypher-epilogue port)
+  (format port ""))
+
+(define (emit-cypher-node id label port)
+  (format port "MERGE (p:Package { id: ~s }) SET p.name = ~s;~%"
+          id label ))
+
+(define (emit-cypher-edge id1 id2 port)
+  (format port "MERGE (a:Package { id: ~s });~%" id1)
+  (format port "MERGE (b:Package { id: ~s });~%" id2)
+  (format port "MATCH (a:Package { id: ~s }), (b:Package { id: ~s }) CREATE UNIQUE (a)-[:NEEDS]->(b);~%"
+          id1 id2))
+
+(define %cypher-backend
+  (graph-backend "cypher"
+                 "Generate Cypher queries."
+                 emit-cypher-prologue emit-cypher-epilogue
+                 emit-cypher-node emit-cypher-edge))
+
+
 \f
 ;;;
 ;;; Shared.
@@ -236,7 +265,8 @@ nodeArray.push(nodes[\"~a\"]);~%"
 
 (define %graph-backends
   (list %graphviz-backend
-        %d3js-backend))
+        %d3js-backend
+        %cypher-backend))
 
 (define* (export-graph sinks port
                        #:key
-- 
2.12.2


[-- Attachment #2: Type: text/plain, Size: 500 bytes --]

Dear Guix,

I would like to add another backend to the 'guix graph' command.  This
backend will return a bunch of queries that can be used to create a
graph database for any database engine that uses openCypher (although I
only know one engine and it's called neo4j, which should be GPLv3 code).

If there was a way to ensure node definitions are written to the output
before the edges, I could simplify the queries a bit.  But I believe it
is quite fast anyway.

Thanks!

Kind regards,
Roel Janssen

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

* bug#26807: [PATCH] graph: Add Cypher backend.
  2017-05-06 21:21 bug#26807: [PATCH] graph: Add Cypher backend Roel Janssen
@ 2017-05-10 20:59 ` Ludovic Courtès
  2017-05-11 12:57   ` Roel Janssen
  0 siblings, 1 reply; 6+ messages in thread
From: Ludovic Courtès @ 2017-05-10 20:59 UTC (permalink / raw)
  To: Roel Janssen; +Cc: 26807

Hello!

Roel Janssen <roel@gnu.org> skribis:

> From 0e9c95ef3473fa7066ccd5991b1c14400aaa7076 Mon Sep 17 00:00:00 2001
> From: Roel Janssen <roel@gnu.org>
> Date: Sat, 6 May 2017 23:15:03 +0200
> Subject: [PATCH] graph: Add Cypher backend.
>
> * guix/graph.scm (%cypher-backend): New variable.

If Neo4j is free software and packageable (is it Java?), why not!

Could you add a few lines in guix.texi under “Invoking guix graph”?
Maybe give an example invocation of cypher and explain how it differs
from the other backends (interactive features maybe?).

Thanks,
Ludo’.

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

* bug#26807: [PATCH] graph: Add Cypher backend.
  2017-05-10 20:59 ` Ludovic Courtès
@ 2017-05-11 12:57   ` Roel Janssen
  2017-05-11 14:03     ` Ludovic Courtès
  0 siblings, 1 reply; 6+ messages in thread
From: Roel Janssen @ 2017-05-11 12:57 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26807

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


Ludovic Courtès writes:

> Hello!
>
> Roel Janssen <roel@gnu.org> skribis:
>
>> From 0e9c95ef3473fa7066ccd5991b1c14400aaa7076 Mon Sep 17 00:00:00 2001
>> From: Roel Janssen <roel@gnu.org>
>> Date: Sat, 6 May 2017 23:15:03 +0200
>> Subject: [PATCH] graph: Add Cypher backend.
>>
>> * guix/graph.scm (%cypher-backend): New variable.
>
> If Neo4j is free software and packageable (is it Java?), why not!

Yes, it's Java, so a lot of work to package.

Fortunately, there is also AgensGraph which is similar to the PostgreSQL
package, and it supports openCypher as well.  So I tried it, and the
queries will work with the latest git checkout of AgensGraph.  Their
latest release does not support automatically creating labels for the
nodes and edges, which was fixed in this commit:

https://github.com/bitnine-oss/agensgraph/commit/5eaecc1d429a08165bb964013ab8ee5516a062e7

So I think the output of what my patch produces should be fine for
multiple implementations of openCypher.

> Could you add a few lines in guix.texi under “Invoking guix graph”?
> Maybe give an example invocation of cypher and explain how it differs
> from the other backends (interactive features maybe?).

Would the attached patch be fine for the manual?

Thanks!

Kind regards,
Roel Janssen


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-doc-Add-documentation-about-cypher-backend-for-guix-.patch --]
[-- Type: text/x-patch, Size: 1081 bytes --]

From fe42c8fe8f50f7b58007f0ef8302307342695e07 Mon Sep 17 00:00:00 2001
From: Roel Janssen <roel@gnu.org>
Date: Thu, 11 May 2017 14:50:09 +0200
Subject: [PATCH] doc: Add documentation about cypher backend for 'guix graph'.

* doc/guix.texi: Add documentation.
---
 doc/guix.texi | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 81aa957c6..a5b787510 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -6197,7 +6197,9 @@ provides a visual representation of the DAG.  By default,
 @uref{http://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.
+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{http://www.opencypher.org/, openCypher} query language.
 The general syntax is:
 
 @example
-- 
2.13.0


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

* bug#26807: [PATCH] graph: Add Cypher backend.
  2017-05-11 12:57   ` Roel Janssen
@ 2017-05-11 14:03     ` Ludovic Courtès
  2017-05-11 14:15       ` Roel Janssen
  0 siblings, 1 reply; 6+ messages in thread
From: Ludovic Courtès @ 2017-05-11 14:03 UTC (permalink / raw)
  To: Roel Janssen; +Cc: 26807

Hi,

Roel Janssen <roel@gnu.org> skribis:

> Ludovic Courtès writes:
>
>> Hello!
>>
>> Roel Janssen <roel@gnu.org> skribis:
>>
>>> From 0e9c95ef3473fa7066ccd5991b1c14400aaa7076 Mon Sep 17 00:00:00 2001
>>> From: Roel Janssen <roel@gnu.org>
>>> Date: Sat, 6 May 2017 23:15:03 +0200
>>> Subject: [PATCH] graph: Add Cypher backend.
>>>
>>> * guix/graph.scm (%cypher-backend): New variable.
>>
>> If Neo4j is free software and packageable (is it Java?), why not!
>
> Yes, it's Java, so a lot of work to package.
>
> Fortunately, there is also AgensGraph which is similar to the PostgreSQL
> package, and it supports openCypher as well.  So I tried it, and the
> queries will work with the latest git checkout of AgensGraph.  Their
> latest release does not support automatically creating labels for the
> nodes and edges, which was fixed in this commit:
>
> https://github.com/bitnine-oss/agensgraph/commit/5eaecc1d429a08165bb964013ab8ee5516a062e7
>
> So I think the output of what my patch produces should be fine for
> multiple implementations of openCypher.

OK.  Do these tools support interactive visualization in addition to
graph queries?

>> Could you add a few lines in guix.texi under “Invoking guix graph”?
>> Maybe give an example invocation of cypher and explain how it differs
>> from the other backends (interactive features maybe?).
>
> Would the attached patch be fine for the manual?

Yes, perfect (please squash it with the patch that adds the new
backend).

Thank you!

Ludo’.

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

* bug#26807: [PATCH] graph: Add Cypher backend.
  2017-05-11 14:03     ` Ludovic Courtès
@ 2017-05-11 14:15       ` Roel Janssen
  2017-05-11 14:29         ` Roel Janssen
  0 siblings, 1 reply; 6+ messages in thread
From: Roel Janssen @ 2017-05-11 14:15 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26807


Ludovic Courtès writes:

> Hi,
>
> Roel Janssen <roel@gnu.org> skribis:
>
>> Ludovic Courtès writes:
>>
>>> Hello!
>>>
>>> Roel Janssen <roel@gnu.org> skribis:
>>>
>>>> From 0e9c95ef3473fa7066ccd5991b1c14400aaa7076 Mon Sep 17 00:00:00 2001
>>>> From: Roel Janssen <roel@gnu.org>
>>>> Date: Sat, 6 May 2017 23:15:03 +0200
>>>> Subject: [PATCH] graph: Add Cypher backend.
>>>>
>>>> * guix/graph.scm (%cypher-backend): New variable.
>>>
>>> If Neo4j is free software and packageable (is it Java?), why not!
>>
>> Yes, it's Java, so a lot of work to package.
>>
>> Fortunately, there is also AgensGraph which is similar to the PostgreSQL
>> package, and it supports openCypher as well.  So I tried it, and the
>> queries will work with the latest git checkout of AgensGraph.  Their
>> latest release does not support automatically creating labels for the
>> nodes and edges, which was fixed in this commit:
>>
>> https://github.com/bitnine-oss/agensgraph/commit/5eaecc1d429a08165bb964013ab8ee5516a062e7
>>
>> So I think the output of what my patch produces should be fine for
>> multiple implementations of openCypher.
>
> OK.  Do these tools support interactive visualization in addition to
> graph queries?

Neo4j does that in a web browser, see:
https://neo4j.com/developer/guide-data-visualization/

AgensGraph does not AFAIK.  It just looks like (and it is) a PostgreSQL
prompt.

>
>>> Could you add a few lines in guix.texi under “Invoking guix graph”?
>>> Maybe give an example invocation of cypher and explain how it differs
>>> from the other backends (interactive features maybe?).
>>
>> Would the attached patch be fine for the manual?
>
> Yes, perfect (please squash it with the patch that adds the new
> backend).
>
> Thank you!
>
> Ludo’.

Great!  I will do that.

Kind regards,
Roel Janssen

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

* bug#26807: [PATCH] graph: Add Cypher backend.
  2017-05-11 14:15       ` Roel Janssen
@ 2017-05-11 14:29         ` Roel Janssen
  0 siblings, 0 replies; 6+ messages in thread
From: Roel Janssen @ 2017-05-11 14:29 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 26807-done


Roel Janssen writes:

> Ludovic Courtès writes:
>
>> Hi,
>>
>> Roel Janssen <roel@gnu.org> skribis:
>>
>>> Ludovic Courtès writes:
>>>
>>>> Hello!
>>>>
>>>> Roel Janssen <roel@gnu.org> skribis:
>>>>
>>>>> From 0e9c95ef3473fa7066ccd5991b1c14400aaa7076 Mon Sep 17 00:00:00 2001
>>>>> From: Roel Janssen <roel@gnu.org>
>>>>> Date: Sat, 6 May 2017 23:15:03 +0200
>>>>> Subject: [PATCH] graph: Add Cypher backend.
>>>>>
>>>>> * guix/graph.scm (%cypher-backend): New variable.
>>>>
>>>> If Neo4j is free software and packageable (is it Java?), why not!
>>>
>>> Yes, it's Java, so a lot of work to package.
>>>
>>> Fortunately, there is also AgensGraph which is similar to the PostgreSQL
>>> package, and it supports openCypher as well.  So I tried it, and the
>>> queries will work with the latest git checkout of AgensGraph.  Their
>>> latest release does not support automatically creating labels for the
>>> nodes and edges, which was fixed in this commit:
>>>
>>> https://github.com/bitnine-oss/agensgraph/commit/5eaecc1d429a08165bb964013ab8ee5516a062e7
>>>
>>> So I think the output of what my patch produces should be fine for
>>> multiple implementations of openCypher.
>>
>> OK.  Do these tools support interactive visualization in addition to
>> graph queries?
>
> Neo4j does that in a web browser, see:
> https://neo4j.com/developer/guide-data-visualization/
>
> AgensGraph does not AFAIK.  It just looks like (and it is) a PostgreSQL
> prompt.
>
>>
>>>> Could you add a few lines in guix.texi under “Invoking guix graph”?
>>>> Maybe give an example invocation of cypher and explain how it differs
>>>> from the other backends (interactive features maybe?).
>>>
>>> Would the attached patch be fine for the manual?
>>
>> Yes, perfect (please squash it with the patch that adds the new
>> backend).
>>
>> Thank you!
>>
>> Ludo’.
>
> Great!  I will do that.

Pushed in 5899fafbfefcd7682aec8f2caaaad3add678a3c4.

Thanks!

Kind regards,
Roel Janssen

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

end of thread, other threads:[~2017-05-11 14:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-06 21:21 bug#26807: [PATCH] graph: Add Cypher backend Roel Janssen
2017-05-10 20:59 ` Ludovic Courtès
2017-05-11 12:57   ` Roel Janssen
2017-05-11 14:03     ` Ludovic Courtès
2017-05-11 14:15       ` Roel Janssen
2017-05-11 14:29         ` Roel Janssen

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).