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/01/12 13:07:28 UTC
[1/2] tinkerpop git commit: Improved the section description for the
recipes appendix
Repository: tinkerpop
Updated Branches:
refs/heads/more-recipes 79a246851 -> 4be8a1b2e
Improved the section description for the recipes appendix
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/0fbfd75a
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/0fbfd75a
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/0fbfd75a
Branch: refs/heads/more-recipes
Commit: 0fbfd75afbb5654b079111e928020250905327a7
Parents: 79a2468
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jan 12 07:38:48 2017 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jan 12 07:38:48 2017 -0500
----------------------------------------------------------------------
docs/src/recipes/appendix.asciidoc | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0fbfd75a/docs/src/recipes/appendix.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/recipes/appendix.asciidoc b/docs/src/recipes/appendix.asciidoc
index 6f9fb2c..9038cea 100644
--- a/docs/src/recipes/appendix.asciidoc
+++ b/docs/src/recipes/appendix.asciidoc
@@ -17,9 +17,11 @@ limitations under the License.
Appendix
========
-Many of the recipes are based on questions and answers provided on the gremlin-users mailing list. This section
-contains a number of traversals from the mailing list that do not easily fit any particular pattern (i.e. a recipe),
-but are nonetheless interesting and thus remain good tools for learning Gremlin.
+Many of the recipes are based on questions and answers provided on the
+link:https://groups.google.com/forum/#!forum/gremlin-users[gremlin-users mailing list] or on
+link:http://stackoverflow.com/questions/tagged/gremlin[StackOverflow]. This section contains those traversals from
+those sources that do not easily fit any particular pattern (i.e. a recipe), but are nonetheless interesting and thus
+remain good tools for learning Gremlin.
[[appendix-a]]
_For each person in a "follows" graph, determine the number of followers and list their names._
[2/2] tinkerpop git commit: Added some additional examples to
appendix recipes.
Posted by sp...@apache.org.
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/more-recipes
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.