Add an appendix to the recipes.

Useful for general example traversals that don't fit nicely into a specific 
recipe or under a specific step in the reference documentation.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/043d1a3a
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/043d1a3a
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/043d1a3a

Branch: refs/heads/TINKERPOP-1602
Commit: 043d1a3aa116b23a46cd1d77bed5ba3c0e4b77a2
Parents: d5404b8
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jan 9 15:19:34 2017 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Jan 9 15:19:34 2017 -0500

----------------------------------------------------------------------
 docs/src/recipes/index.asciidoc | 81 +++++++++++++++++++++++++++++++++++-
 1 file changed, 80 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/043d1a3a/docs/src/recipes/index.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/recipes/index.asciidoc b/docs/src/recipes/index.asciidoc
index 8ffc358..2e88ac5 100644
--- a/docs/src/recipes/index.asciidoc
+++ b/docs/src/recipes/index.asciidoc
@@ -133,4 +133,83 @@ GitHub and JIRA are linked.  As mentioned earlier in this 
section, the recipe wi
 committers prior to merging. This process may take several days to complete. 
We look forward to receiving your
 submissions!
 
-
+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.
+
+[[appendix-a]]
+_For each person in a "follows" graph, determine the number of followers and 
list their names._
+
+[gremlin-groovy]
+----
+g.addV('name','marko').as('marko').
+  addV('name','josh').as('josh').
+  addV('name','daniel').as('daniel').
+  addV('name','matthias').as('matthias').
+  addE('follows').from('josh').to('marko').
+  addE('follows').from('matthias').to('josh').
+  addE('follows').from('daniel').to('josh').
+  addE('follows').from('daniel').to('marko').iterate()
+g.V().as('p').
+  map(__.in('follows').values('name').fold()).
+  group().by(select('p').by('name')).
+          by(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._
+
+[gremlin-groovy,modern]
+----
+g.V().hasLabel("person").as("p").
+  out("created").as("s").
+  map(__.in("created").
+    where(neq("p")).values("name").fold()).
+  group().by(select("p").by("name")).
+    by(group().by(select("s").by("name")).
+    by(project("numCoworkers","coworkers").
+         by(count(local)).by())).next()
+----
+
+[[appendix-c]]
+_Assuming a graph of students, classes and times, detect students who have a 
conflicting schedule._
+
+[gremlin-groovy]
+----
+g.addV(label, "student", "name", "Pete").as("s1").
+  addV(label, "student", "name", "Joe").as("s2").
+  addV(label, "class", "name", "Java's GC").as("c1").
+  addV(label, "class", "name", "FP Principles").as("c2").
+  addV(label, "class", "name", "Memory Management in C").as("c3").
+  addV(label, "class", "name", "Memory Management in C++").as("c4").
+  addV(label, "timeslot", "date", "11/25/2016", "fromTime", "10:00", "toTime", 
"11:00").as("t1").
+  addV(label, "timeslot", "date", "11/25/2016", "fromTime", "11:00", "toTime", 
"12:00").as("t2").
+  addE("attends").from("s1").to("c1").
+  addE("attends").from("s1").to("c2").
+  addE("attends").from("s1").to("c3").
+  addE("attends").from("s1").to("c4").
+  addE("attends").from("s2").to("c2").
+  addE("attends").from("s2").to("c3").
+  addE("allocated").from("c1").to("t1").
+  addE("allocated").from("c1").to("t2").
+  addE("allocated").from("c2").to("t1").
+  addE("allocated").from("c3").to("t2").
+  addE("allocated").from("c4").to("t2").iterate()
+g.V().hasLabel("student").as("s").
+  out("attends").as("c").
+  out("allocated").as("t").
+  select("s").
+  out("attends").
+  where(neq("c")).
+  out("allocated").
+  where(eq("t")).
+  group().
+    by(select("s").by("name")).
+    by(group().by(select("t").by(valueMap("fromTime","toTime"))).
+               by(select("c").dedup().values("name").fold())).next()
+----
\ No newline at end of file

Reply via email to