You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2017/09/13 15:16:57 UTC
[2/3] tinkerpop git commit: Added a basic sum/division recipe using
sack CTR
Added a basic sum/division recipe using sack CTR
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/736cb261
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/736cb261
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/736cb261
Branch: refs/heads/master
Commit: 736cb261c493acc7831c761a8bc1c5351d1efba0
Parents: e9b364a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Sep 13 11:16:16 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Sep 13 11:16:16 2017 -0400
----------------------------------------------------------------------
docs/src/recipes/appendix.asciidoc | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/736cb261/docs/src/recipes/appendix.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/recipes/appendix.asciidoc b/docs/src/recipes/appendix.asciidoc
index 22ce1a7..a65b8f8 100644
--- a/docs/src/recipes/appendix.asciidoc
+++ b/docs/src/recipes/appendix.asciidoc
@@ -174,6 +174,31 @@ g.withSack(0).V().values("age").sack(sum).sack(sum).sack() // multiply by 2 (sim
g.withSack(0).V().values("age").sack(sum).sack(mult).by(constant(2)).sack() // multiply by 2 (generally useful for multiplications by n)
----
+_Method for doing a sum with division._
+
+[gremlin-groovy]
+----
+g.addV().property(id, "a").as("a").
+ addV().property(id, "b").as("b").
+ addE("link").from("a").to("b").
+ addE("link").from("b").to("a").
+ addE("link").from("b").to("a").iterate()
+g.withSack(0d).
+ V("a").as("a").
+ V("b").as("b").
+ project("ab", "ba").
+ by(inE("link").where(outV().as("a")).count()).
+ by(outE("link").where(inV().as("a")).count()).
+ sack(sum).by(select("ab")).
+ sack(div).by(select("ba")).
+ project("a", "b", "#(a,b)", "#(b,a)", "#(a,b) / #(b,a)").
+ by(select("a")).
+ by(select("b")).
+ by(select("ab")).
+ by(select("ba")).
+ by(sack())
+----
+
[[appendix-g]]
_Dropping a vertex, as well as the vertices related to that dropped vertex that are connected by a "knows" edge in the
"modern" graph_