How to find all edges between two vertice types

Hi,
I have a graph with vertices with a predicate “type”, and various kinds of edges connecting them.
I want to, for a given set of vertices, find all vertices of a given type that are directly connected to them, no mattering the kind of edge.

Thanks.

Not sure If I fully understood. But try to use reverse edges
Can you explain a bit more? also have you run our tour?

{
  q(func: has(type), first: 100){
     uid
     type.name
    ~type {
       uid
       expand(_all_)
    }
  }
}

Cheers.

Thanks. I have ran the tour. But I’ll try to elaborate, using an example.

This is my schema:

<name>: string .
<type>: string @index(hash) .
<ref>: int @index(int) .
<parent_of>: uid @reverse .
<relates>: uid @reverse .
<blocks>: uid @reverse .

I want to find all “Requirement” type vertices that have any kind of edge – “parent_of”, “relates”, “blocks”, or any reverse of those – towards “Tests” type vertices.
I’ve tried something like

{
  q(func: eq(type, "Requirement")) {
    expand(_all_) @filter(eq(type, "Tests")) {
       name
    }
  }
}

But the expand(_all_) and @filter do not go along well…

Expand directives don’t accept filters at all. You have to manually set all edges and use expand All. Like so:


{
  q(func: eq(type, "Requirement")) {
    parent_of @filter(eq(type, "Tests")) {
       expand(_all_)
    }
    relates @filter(eq(type, "Tests")) {
       expand(_all_)
    }
    blocks @filter(eq(type, "Tests")) {
       expand(_all_)
    }
  }
}

Check if they are reverse tho. And You may could use Recurse Query

Ok, I see. Thank you then!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.