graph - ArangoDB - How to find nodes not related to a specific one? -
for clarity purpose, step names used identifiers
i have following directed acyclic graph (dag):
what i'm trying select node, , find other nodes not connected directly selected one, in outbound direction.
for example: if select "root step", query should return "test step 3", since 1 not connected directly "root step".
however, if select "test step 2", should only return "test step 3", , not "test step", because "test step* @ same level "test step 2" is.
for now, here how do:
i store, in every "step", list of parents has array. (test step has ["root step"], etc.)
my query follows ( test step 2 example ):
for v, e in 0..10 outbound "steps/test step 2" steps_relations filter e._from != "steps/test step 2" filter e._to != "steps/test step 2" filter v._id != "steps/test step 2" filter ["root step"] none in v.parents return {id: v._key, name: v.name } for returns empty result instead of expected ("test step 3"). appreciated
i have managed fix this. here how did it:
first, added 2 fields each 1 of "steps" document:
root: equals
truewhen root of tree (like "root step"). otherwise references internal id of root stepdepth: equals 0 root step, incremented. when add step another, new step's depth equals (parent + 1) if result bigger 1 stored.
once have this, query looks follows:
situation: want list steps can linked "test step 2"
for step, relation in 0..10 "steps/root step" steps_relations filter step.depth > 1 /* depth of test step 2 wich 1 */ filter relation._from != "steps/test step 2" return item this returns "test step 3"

Comments
Post a Comment