simplePath

Use to prevent a traverser from repeating a path through the graph.

Synopsis

simplePath()
Table 1. Legend
Syntax conventions Description
Lowercase and uppercase Literal keyword. Includes ().
Italics Variable value. Replace with a user-defined value.
[] Optional. Square brackets ( [] ) surround optional command arguments. Do not type the square brackets.
{} Group. Braces ( {} ) identify a group to choose from. Do not type the braces.
| Or. A vertical bar ( | ) separates alternative elements. Type any one of the elements. Do not type the vertical bar.
... Repeatable. An ellipsis ( ... ) indicates that you can repeat the syntax element as often as required.

Description

The simplePath() step is a filter step. When it is important that a traverser not repeat its path through the graph, this step should be used.

Examples

Find the expanded neighborhood of all the people who know each other, without repeating any edges:
g.V().has('person', 'name', 'John Doe').
  repeat(both('knows').simplePath()).
    emit().
  path().
    by('name')
  *.objects()
  *.join(" > ") 
Note: This query uses Groovy notation (*.objects, *.join) in a Gremlin query, to return pretty results.
The results:
"John Doe > John Smith",
"John Doe > Jane Doe",
"John Doe > Betsy Jones",
"John Doe > John Smith > Jane Doe",
"John Doe > Jane Doe > Sharon Smith",
"John Doe > Jane Doe > John Smith",
"John Doe > Betsy Jones > Sharon Smith",
"John Doe > John Smith > Jane Doe > Sharon Smith",
"John Doe > Jane Doe > Sharon Smith > Betsy Jones",
"John Doe > Jane Doe > Sharon Smith > Jim Walsh",
"John Doe > Betsy Jones > Sharon Smith > Jane Doe",
"John Doe > Betsy Jones > Sharon Smith > Jim Walsh",
"John Doe > John Smith > Jane Doe > Sharon Smith > Betsy Jones",
"John Doe > John Smith > Jane Doe > Sharon Smith > Jim Walsh",
"John Doe > Betsy Jones > Sharon Smith > Jane Doe > John Smith"