I have a graph that is essentially bimodal, like the marvel database - Heroes connected to Comics and vice versa. No connections can be created between Heroes nor from Comic to Comic.
I'm working on a graph visualization and trying to remove noise. I have a list of heroes and want to return all the comics they're in. However, I only want the ones where the hero is connected via a comic to another hero within the list.
My solution thus far has been a pattern match with two where clauses and an OPTIONAL MATCH:
MATCH (c:Comic)-[:APPEARED_IN]-(:Hero)-[:APPEARED_IN]-(c1:Comic)
WHERE c.name in ["AVF 5", "COC 1", "H2 251", "H2 252", "M/PRM 35", "M/PRM 36", "M/PRM 37", "WI? 9", "AVF 4", "CM 51", "Q 14", "Q 16", "T 208", "T 214", "T 215", "T 216", "T 440", "CA3 36", "SLEEP 19", "SLEEP 1", "SLEEP 2", "W2 52", "W2 53", "XFOR 108", "XFOR 109"]
AND c1.name in ["AVF 5", "COC 1", "H2 251", "H2 252", "M/PRM 35", "M/PRM 36", "M/PRM 37", "WI? 9", "AVF 4", "CM 51", "Q 14", "Q 16", "T 208", "T 214", "T 215", "T 216", "T 440", "CA3 36", "SLEEP 19", "SLEEP 1", "SLEEP 2", "W2 52", "W2 53", "XFOR 108", "XFOR 109"]
AND id(c) <> id(c1)
WITH distinct c
OPTIONAL MATCH (c)-[r:APPEARED_IN]-(h:Hero)
RETURN c, r, h
This has worked with a list of around 100. However, I tried a list of over 2,000 and killed the connection.
Is there a more elegant, optimized way to do this?
The profile plan looks like this: