Let's say I have this graph (link to Gremlify):
I need a query to get a vertex with all its child vertices (up to a certain depth). We already have one that seems to work:
g.V("4840")
.repeat(outE().inV().simplePath())
.times(5)
.emit()
.path()
.by(valueMap(true))
The result is:
[
[
{
"id": 4840,
"label": "Vertex"
},
{
"id": 4842,
"label": "child"
},
{
"id": 4838,
"label": "Vertex"
}
]
]
So I now have the vertex with the edge and the child vertex. Great. But what if I use id 4836? Then I get an empty array. This is because this vertex doesn't have any outgoing edges. Is there a way to construct a query that will give me a vertex with its linked vertices, but also the vertex itself if it doesn't have any edges?
You can play around with this here.