Hello everyone,
I would like to return a subgraph in edgelist form for a relationship (:CITES
) linking nodes of the same label (Family
) where nodes are filtered by several conditions.
I have a query which mostly does what I want but seems somewhat inefficient as it duplicates the filter steps:
MATCH (sc:SubclassCPC)<-[:CLASSIFIED_AS]-(a1:Application)-[:BELONGS_TO]->(f1:Family)
MATCH (sc:SubclassCPC)<-[:CLASSIFIED_AS]-(a2:Application)-[:BELONGS_TO]->(f2:Family)
MATCH (a1)-[:FILED_IN]-(c:Country)
MATCH (a2)-[:FILED_IN]-(c:Country)
WHERE
sc.code IN ["D01F"] AND
a1.granted = true AND a2.granted = true AND
a1.filing_year >= 1990 AND a2.filing_year >= 1990 AND
a1.filing_year <= 2014 AND a2.filing_year <= 2014 AND
c.code IN ["EU", "US"]
MATCH (f1)-[:CITES]->(f2)
RETURN DISTINCT
f1.family_id AS citing_id,
f2.family_id AS cited_id
I'm sure it is possible to filter families once and then return all the :CITES
relationships among the filtered set of families (in edgelist form) but I couldn't find the syntax. Does anyone have any suggestions?