Reputation: 11
I am writing a graph traversal query in AQL (arangodb 3.1.22) where for some of the paths that are returned, I get a vertex within the path object that is not connected to any of the edges returned within the path object (i.e. the _from/_to property of the edges does not match the vertex _id).
I was working under the assumption that the path object only returned the vertices and edges on that path. Is this a wrong assumption?
Upvotes: 1
Views: 248
Reputation: 11855
If you pass the starting point as string, no vertex has to exist at all for the traversal:
FOR v, e IN 1..10 OUTBOUND "nodes/non-existing-start" edges
RETURN { vertex: v, _from: e._from, _to: e._to }
Data (vertices in collection nodes
and edges in edges
):
non-existing-start
|
v
non-existing-1
|
v
non-existing-2
|
v
non-existing-3
What it does is traverse along the edges (_from
and _to
properties), which do exist, using the edge index. The collection nodes
has to exist, but it is not tested whether the vertices referenced in _from
and _to
actually exist in that collection. The query result is:
[
{
"vertex": null,
"_from": "nodes/non-existing-start",
"_to": "nodes/non-existing-1"
},
{
"vertex": null,
"_from": "nodes/non-existing-1",
"_to": "nodes/non-existing-2"
},
{
"vertex": null,
"_from": "nodes/non-existing-2",
"_to": "nodes/non-existing-3"
}
]
As you can see, the vertices are null
, so they don't exist.
You may use a managed graph and the general-graph module to also delete edges connected to a vertex when deleting the vertex to ensure consistency.
Upvotes: 0