Reputation: 63
I've got a complex graph. I am using a traversal (through ArangoJS) with also quite complex expanderFunction and traversalVisitor.
For this traversal, I'd like to know if it is possible to create dynamic relations (or fake relations) between some nodes in my graph): That is, based on some attributes in a vertex, let the traversal pursue the graph exploration as if there was an edge between the current vertex and another one.
I've tried to trick the expander function, pushing a fake edge ( from the current vertex to another not related one in the graph) into the traversal data structures, something like:
if (complex_criteria(vertex)) {
var unconnectedVertexId = ...
var unconnectedVertex = someCollection.document(unconnectedVertexId);
connected.push({ edge:{_id:'newId', _from:vertex._id, _to:unconnectedVertex._id}, vertex: unconnectedVertex });
}
..
return connected;
This did not work. ( traversal options were: direction: 'outbound', strategy: "depthfirst" )
Any better idea ?
Thanks !
Upvotes: 0
Views: 144
Reputation: 3267
i think there is a slight mistake in you code:
if (complex_criteria(vertex)) {
var unconnectedVertexId = ...
var unconnectedVertex = someCollection.document(unconnectedVertexId);
connected.push({ edge:{_id:'newId', _from:vertex._id, _to:unconnectedVertex._id}, vertex: unconnectedVertex });
}
..
return connected;
the "fake-edge" _to
has to point to unconnectedVertex._id
, not the object itself.
Can you check if this fixes the problem already?
Upvotes: 2