I am wondering how to return all the nodes with Label_C
which have at least one node with LABEL_A
in common if the number of the output nodes connected to such a node with LABEL_A
is greater than or equal to a threshold. The target node can thus be reached through a path from any of the desired output nodes.
The structure is (common:Label_A)-[:REL_1]->(:LABEL_B)<-[:REL_2]-(output:Label_C)
My attempt:
MATCH (common:Label_A)-[:REL_1]->(:LABEL_B)<-[:REL_2]-(output:Label_C)
WITH DISTINCT common, output, count(id(common)) AS cnt WHERE cnt >= [THRESHOLD]
RETURN DISTINCT output
Look at the appended image for an example. The threshold is set to be 3.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…