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 2015/03/27 21:55:44 UTC

[4/6] incubator-tinkerpop git commit: Add docs for SubgraphStrategy.

Add docs for SubgraphStrategy.


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

Branch: refs/heads/master
Commit: 195488798f523f852df545dbf539001a9d951971
Parents: 8593123
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Mar 27 16:39:05 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Mar 27 16:39:05 2015 -0400

----------------------------------------------------------------------
 docs/src/the-traversal.asciidoc | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/19548879/docs/src/the-traversal.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/the-traversal.asciidoc b/docs/src/the-traversal.asciidoc
index a517f23..ff746e0 100644
--- a/docs/src/the-traversal.asciidoc
+++ b/docs/src/the-traversal.asciidoc
@@ -1661,6 +1661,24 @@ ReadOnlyStrategy
 
 `ReadOnlyStrategy` is largely self-explanatory.  A `Traversal` that has this strategy applied will throw an `IllegalStateException` if the `Traversal` has any mutating steps within it.
 
+SubgraphStrategy
+================
+
+`SubgraphStrategy` is quite similar to `PartitionStrategy` in that it restrains a `Traversal` to certain vertices and edges as determined by a `Predicate` defined individually for each.
+
+[gremlin-groovy]
+----
+graph = TinkerFactory.createModern()
+vertexCriterion = { vertex -> true }
+edgeCriterion = { edge -> (int) edge.id() >= 8 && (int) edge.id() <= 10}
+strategy = SubgraphStrategy.build().vertexPredicate(vertexCriterion).edgePredicate(edgeCriterion).create()
+g = GraphTraversalSource.build().with(strategy).create(graph)
+g.V() //// shows all vertices as they all pass the vertexCriterion
+g.E() //// shows only the edges defined in the edgeCriterion
+----
+
+Note that `SubgraphStrategy` directly passes the edge and vertex criterion `Predicate` objects  to an injected `filter` step and as such may not take advantage of important optimizations provided by the various `Graph` implementations (given the use of lambda expressions).
+
 Domain Specific Languages
 -------------------------