gremlin> g=TinkerFactory.createModern().traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin> g.V(1).out().out().in().path()
==>[v[1],v[4],v[5],v[4]]
==>[v[1],v[4],v[3],v[1]]
==>[v[1],v[4],v[3],v[4]]
==>[v[1],v[4],v[3],v[6]]
// assign the first traversal to p
gremlin> p=g.V(1).out().out().in().path().by(label()).next()
==>person
==>person
==>software
==>person
gremlin> (1..p.size()-1).stream().map{[depth:it, label:p[it]]}.collect()
==>[depth:1,label:person]
==>[depth:2,label:software]
==>[depth:3,label:person]
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/3eea97f0-59ec-4dd8-8ced-6651b0a64fd3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/CA%2Bf9seX9TTo_3z_-tx8x3MMTJ1pvg7LQ35b1VMhSb%3DE15jC3OA%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/3eea97f0-59ec-4dd8-8ced-6651b0a64fd3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
v1 = graph.addVertex(label, 'l1', 'spike', '1324', 'myId', 'id-1');
v2 = graph.addVertex(label, 'l2', 'spike', '1324', 'myId', 'id-2');v3 = graph.addVertex(label, 'l3', 'spike', '1324', 'myId', 'id-3');v4 = graph.addVertex(label, 'l4', 'spike', '1324', 'myId', 'id-4');v1.addEdge('child', v2);v2.addEdge('child', v3);v3.addEdge('child', v4);
bag = [depth:0, previousId:'', id:''];
addDepthToBag = { m, v -> m.depth = m.depth + v; m; };addVertexToBag = { m, v -> m.vertex = v; m; };
g.withSack{bag}{it.clone()}.V().hasLabel("l1").emit().repeat( out("child") .sack(addIdToBag) .by('myId') .sack(addDepthToBag) .by(constant(1)) .sack(addVertexToBag)).sack()
[
{
"depth": 0,
"previousId": "",
"id": ""
},
{
"depth": 1,
"previousId": "",
"id": "id-2",
"vertex": {
"id": 692232,
"label": "l2",
"type": "vertex",
"properties": {
"myId": [
{
"id": "hq0x-eu4o-12px",
"value": "id-2"
}
],
"spike": [
{
"id": "hpmp-eu4o-11xh",
"value": "1324"
}
]
}
}
},
{
"depth": 2,
"previousId": "id-2",
"id": "id-3",
"vertex": {
"id": 626816,
"label": "l3",
"type": "vertex",
"properties": {
"myId": [
{
"id": "g7io-dfnk-12px",
"value": "id-3"
}
],
"spike": [
{
"id": "g74g-dfnk-11xh",
"value": "1324"
}
]
}
}
},
{
"depth": 3,
"previousId": "id-3",
"id": "id-4",
"vertex": {
"id": 639224,
"label": "l4",
"type": "vertex",
"properties": {
"myId": [
{
"id": "gwtb-dp88-12px",
"value": "id-4"
}
],
"spike": [
{
"id": "gwf3-dp88-11xh",
"value": "1324"
}
]
}
}
}
]
g.withSack{bag}{it.clone()}.
V().hasLabel("l1").
sack(addIdToBag).
by('myId').
sack(addDepthToBag).
by(constant(1)).
sack(addVertexToBag).
emit().
repeat(
out("child").
sack(addIdToBag).
by('myId').
sack(addDepthToBag).
by(constant(1)).
sack(addVertexToBag)).sack()
g.withSack{bag}{it.clone()}.V().hasLabel("l1").emit()
.sack(addIdToBag).by('myId').sack(addDepthToBag).by(constant(1)).sack(addVertexToBag).repeat( out("child") .sack(addIdToBag) .by('myId') .sack(addDepthToBag) .by(constant(1)) .sack(addVertexToBag)).sack()
java.lang.NullPointerException
at org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatStep.standardAlgorithm(RepeatStep.java:185)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.ComputerAwareStep.processNextStart(ComputerAwareStep.java:46)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:143)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.next(ExpandableStepIterator.java:50)
at org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectStep.processNextStart(SideEffectStep.java:38)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:143)
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/0174ffcc-9818-4bc6-843b-4b9df19c1ce4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/0174ffcc-9818-4bc6-843b-4b9df19c1ce4%40googlegroups.com.To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.