cdsousa
(Cristóvão Duarte Sousa)
December 7, 2018, 4:43pm
1
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.
MichelDiz
(Michel Diz)
December 7, 2018, 10:27pm
2
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.
cdsousa
(Cristóvão Duarte Sousa)
December 7, 2018, 10:53pm
3
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…
MichelDiz
(Michel Diz)
December 7, 2018, 11:11pm
4
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
cdsousa
(Cristóvão Duarte Sousa)
December 7, 2018, 11:22pm
5
Ok, I see. Thank you then!
system
(system)
Closed
January 6, 2019, 11:22pm
6
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.