tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [03/24] tinkerpop git commit: Provided a max depth traversal that doesn't require path calculations CTR
Date Fri, 29 Sep 2017 18:00:16 GMT
Provided a max depth traversal that doesn't require path calculations CTR


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

Branch: refs/heads/TINKERPOP-1784
Commit: 0bffe25dd0c34b0a187da364a88c6862ff3e25e4
Parents: d028a9c
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Fri Sep 29 12:41:28 2017 -0400
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Fri Sep 29 12:41:28 2017 -0400

----------------------------------------------------------------------
 docs/src/recipes/tree.asciidoc | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0bffe25d/docs/src/recipes/tree.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/recipes/tree.asciidoc b/docs/src/recipes/tree.asciidoc
index da74a3d..08120be 100644
--- a/docs/src/recipes/tree.asciidoc
+++ b/docs/src/recipes/tree.asciidoc
@@ -107,7 +107,7 @@ g.withComputer().
   select(keys).limit(1)
 ----
 
-<1> The main difference for OLAP is the use of `aggregate()` over the mid-traversal`V()`.
+<1> The main difference for OLAP is the use of `aggregate()` over the mid-traversal
`V()`.
 
 === Maximum Depth
 
@@ -133,7 +133,7 @@ g.V().has('name','C').repeat(__.in()).emit().path().count(local).max()
 ----
 
 image:gremlin-max-depth.png[float=right,width=350]The traversals shown above are fairly straightforward.
The traversal
-beings at a particlar starting vertex, traverse in on the "hasParent" edges emitting all
vertices as it goes. It
+beings at a particular starting vertex, traverse in on the "hasParent" edges emitting all
vertices as it goes. It
 calculates the path length and then selects the longest one. While this approach is quite
direct, there is room for
 improvement:
 
@@ -152,6 +152,20 @@ those without incoming edges). Second, all results save the last one
can be igno
 the one at the deepest point in the tree). In this way, the path and path length only need
to be calculated for a
 single result.
 
+The previous approaches to calculating the maximum depth use path calculations to achieve
the answer. Path calculations
+can be expensive and if possible avoided if they are not needed. Another way to express a
traversal that calculates
+the maximum depth is to use the `sack()` step:
+
+[gremlin-groovy,existing]
+----
+g.withSack(1).V().has('name','F').
+  repeat(__.in().sack(sum).by(constant(1))).emit().
+  sack().max()
+g.withSack(1).V().has('name','C').
+  repeat(__.in().sack(sum).by(constant(1))).emit().
+  sack().max()
+----
+
 === Time-based Indexing
 
 Trees can be used for modelling time-oriented data in a graph. Modeling time where there
are "year", "month" and "day"


Mime
View raw message