[
https://issues.apache.org/jira/browse/TINKERPOP3-968?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15023850#comment-15023850
]
pieter martin commented on TINKERPOP3-968:
------------------------------------------
My initial idea is as follows,
{{GraphTraversal.to(direction, edgeLabels)}}
gets a first boolean parameter.
{{GraphTraversal.to(optional, direction, edgeLabels)}}
The optional parameter defaults to false making this ticket backwards
compatible.
{noformat}
GraphTraversal.out(optional, edgeLabels)
GraphTraversal.in(optional, edgeLabels)
{noformat}
Eg,
{noformat}
a1 -> b1 -> c1
|
-> b2
a2
{noformat}
{noformat}
List vertices = g.V().hasLabel('A').out(true).out(true).toList();
assertEquals(3, vertices.size());
assertTrue(vertices.contains(c1));
assertTrue(vertices.contains(b2));
assertTrue(vertices.contains(a2));
{noformat}
> Add first class support for an optional traversal
> -------------------------------------------------
>
> Key: TINKERPOP3-968
> URL: https://issues.apache.org/jira/browse/TINKERPOP3-968
> Project: TinkerPop 3
> Issue Type: Improvement
> Components: process
> Affects Versions: 3.1.0-incubating
> Reporter: pieter martin
>
> Both SparQL and Cypher use the "Optional" keyword to indicate an optional
> traversal. SQL uses the "left join".
> Gremlin has no first class support for an optional traversal. It can be
> achieved with the choose step but it is verbose, unintuitive and not what the
> choose step is intended for.
> The benefits of optional traversals are many. In particular it makes it
> trivial to load complete subgraphs/trees with one easy to read intuitive
> gremlin statement.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)