2

I'm trying to get the neighborhood of a node in ArangoDB.

When I do this to get IN nodes:

 for v in Protein_G_H
    filter v._to == "p2/9606.ENSP00000326759"
    return v 

I get a result. Doing this to get OUT nodes

for v in Protein_G_H
    filter v._from == "p2/9606.ENSP00000326759"
    return v 

I also get result but doing this:

for v in Protein_G_H
    filter v._to == "p2/9606.ENSP00000326759"
    filter v._from == "p1/9606.ENSP00000326759"
    return v 

--or--

for v in Protein_G_H
    filter v._to == "p2/9606.ENSP00000326759"
      and v._from == "p1/9606.ENSP00000326759"
    return v 

to get in and out nodes I get nothing. What is the problem?

CodeManX
  • 11,159
  • 5
  • 49
  • 70
Muna arr
  • 353
  • 2
  • 13

1 Answers1

2

If you want to retrieve in and out nodes, you need to test if the _from or _to property of the edge is equal to the node you want to get the neighbors for:

for e in Protein_G_H
    filter e._to == "p2/9606.ENSP00000326759"
      or e._from == "p2/9606.ENSP00000326759"
    return e

I would recommend to use AQL graph traversal however to retrieve neighbor vertices:

for v in 1..1 any "p2/9606.ENSP00000326759" Protein_G_H
    return v

This will return first degree neighbor vertices of vertex 9606.ENSP00000326759 in the vertex collection p2, following the edges in edge collection Protein_G_H in any direction (either _from or _to must be equal to p2/9606.ENSP00000326759).

CodeManX
  • 11,159
  • 5
  • 49
  • 70