Added some additional examples to appendix recipes.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/4be8a1b2 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/4be8a1b2 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/4be8a1b2 Branch: refs/heads/TINKERPOP-1602 Commit: 4be8a1b2ec8c15aee1c84199e560687a1e3fdf39 Parents: 0fbfd75 Author: Stephen Mallette <sp...@genoprime.com> Authored: Thu Jan 12 08:06:07 2017 -0500 Committer: Stephen Mallette <sp...@genoprime.com> Committed: Thu Jan 12 08:06:07 2017 -0500 ---------------------------------------------------------------------- docs/src/recipes/appendix.asciidoc | 23 +++++++++++++++++++++++ docs/src/recipes/duplicate-edge.asciidoc | 18 ++++++++++++++++++ 2 files changed, 41 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4be8a1b2/docs/src/recipes/appendix.asciidoc ---------------------------------------------------------------------- diff --git a/docs/src/recipes/appendix.asciidoc b/docs/src/recipes/appendix.asciidoc index 9038cea..9d0ea7b 100644 --- a/docs/src/recipes/appendix.asciidoc +++ b/docs/src/recipes/appendix.asciidoc @@ -43,6 +43,29 @@ g.V().as('p'). by(count(local)).by()).next() ---- +It might also be alternatively written as: + +[gremlin-groovy,existing] +---- +g.V().group(). + by('name'). + by(project('numFollowers','followers'). + by(__.in('follows').count()). + by(__.in('follows').values('name').fold())).next() +---- + +or even: + +[gremlin-groovy,existing] +---- +g.V().group(). + by('name'). + by(__.in('follows').values('name').fold(). + project('numFollowers','followers'). + by(count(local)). + by()).next() +---- + [[appendix-b]] _In the "modern" graph, show each person, the software they worked on and the co-worker count for the software and the names of those co-workers._ http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4be8a1b2/docs/src/recipes/duplicate-edge.asciidoc ---------------------------------------------------------------------- diff --git a/docs/src/recipes/duplicate-edge.asciidoc b/docs/src/recipes/duplicate-edge.asciidoc index ed56106..a62716e 100644 --- a/docs/src/recipes/duplicate-edge.asciidoc +++ b/docs/src/recipes/duplicate-edge.asciidoc @@ -86,6 +86,24 @@ the outgoing vertex, the edge label, and the incoming vertex as the key, with th value. <4> The rest of the traversal is the same as the previous one. +Note that the above traversal could also be written using `match` step: + +[gremlin-groovy,existing] +---- +g.V().match( + __.as("ov").outE().as("e"), + __.as("e").inV().as("iv"), + __.as("iv").inE().as("ie"), + __.as("ie").outV().as("ov")). + where("ie",neq("e")). + where("ie",eq("e")).by(label). + select("ie"). + group(). + by(select("ov","e","iv").by().by(label)). + unfold().select(values). + where(count(local).is(gt(1))) +---- + A third way to approach this problem would be to force a link:https://en.wikipedia.org/wiki/Depth-first_search[depth-first search]. The previous examples invoke traversal strategies that force a link:https://en.wikipedia.org/wiki/Breadth-first_search[breadth first search] as a performance optimization.