From 0301f74373230810122abdfd76e68a83387452e0 Mon Sep 17 00:00:00 2001 From: Mario Wenzel <maweki@gmail.com> Date: Fri, 4 Oct 2019 20:11:41 +0200 Subject: [PATCH] added path2 scripts --- jena/path2.qry | 2 ++ neo4j/path2.qry | 10 ++++++++++ souffle/path2.dl | 15 +++++++++++++++ sql/path2.sql | 4 ++++ 4 files changed, 31 insertions(+) create mode 100644 jena/path2.qry create mode 100644 neo4j/path2.qry create mode 100644 souffle/path2.dl create mode 100644 sql/path2.sql diff --git a/jena/path2.qry b/jena/path2.qry new file mode 100644 index 0000000..13a3252 --- /dev/null +++ b/jena/path2.qry @@ -0,0 +1,2 @@ +prefix : <http://example.org/stuff/1.0/> +SELECT (count(*) as ?resultcount) WHERE {?a :par / :par ?b} diff --git a/neo4j/path2.qry b/neo4j/path2.qry new file mode 100644 index 0000000..f9d2433 --- /dev/null +++ b/neo4j/path2.qry @@ -0,0 +1,10 @@ +MATCH (n) +DETACH DELETE n; + +LOAD CSV FROM 'file://INSTANCE' AS line +MERGE (a:Node {n: toInteger(line[0])}) +MERGE (b:Node {n: toInteger(trim(line[1]))}) +CREATE (a)-[:PAR]->(b); + +MATCH (a)-[:PAR]->(t)-[:PAR]->(b) +RETURN COUNT(DISTINCT [a,b]); diff --git a/souffle/path2.dl b/souffle/path2.dl new file mode 100644 index 0000000..0b07c6a --- /dev/null +++ b/souffle/path2.dl @@ -0,0 +1,15 @@ + +// +// par - "parent"/"edge" relation +// +.decl par (n:number, m:number) +.input par(IO=file, filename="INSTANCE") +// par(1,2). +// par(2,3). + +//.decl path2 (n:number, m:number) output +.decl path2 (n:number, m:number) +//.output path2(IO=stdout) +.printsize path2 + +path2(X, Y) :- par(X, Z), par(Z, Y). diff --git a/sql/path2.sql b/sql/path2.sql new file mode 100644 index 0000000..8d9a599 --- /dev/null +++ b/sql/path2.sql @@ -0,0 +1,4 @@ + +WITH path2(a,b) AS ( + SELECT p1.a, p2.b from par p1 JOIN par p2c ON p1.b = p2.a +) SELECT Count(*) FROM path2; -- GitLab