Need Help with returning the right nodes

Hi! :slight_smile:
Here is a very basic 4 node representation:

(origin:Drug {id:'A'})-[:CONTAINS]->(cmp475:Compound {id: '475'})<-[:CONTAINS {weight: 2}]-(candidate:Drug 
{id: 'B'}), (candidate2:Drug {id: 'C'})-[:CONTAINS {weight: 2}]->(cmp475), 

I am trying to return all the :Drug's that are not [:Incompatible_with]-(origin) and also not [:Incompatible_with]->(candidate2), aka the other candidates. I've started with this query:

match (origin)-[r1:CONTAINS]-(c)-[r2:CONTAINS]-(candidate) 
WHERE = 'A' and  not (candidate)-[:Incompatible_with]-(origin) 
AND type(r1)=type(r2)
RETURN AS origin, AS candidate, collect(r2.weight) AS weight order by weight desc

But it still returns C, when I also need to just return B. I've tried with adding other longer MATCH clauses that only result in no changes :frowning:

Would anyone be able to help tell me what I'm missing?

Try this query:

MATCH (c:Drug)-[:Incompatible_with]->(d)
MATCH (o:Drug)-[r1:CONTAINS]->(g:Compound)<-[r2:CONTAINS]-(f)
WHERE <> AND = "A"
RETURN,, collect(r2.weight) as Weight ORDER BY Weight;

Thank you for your reply!!

^This worked super for my small example above, but when I tried adding to the original db and made another node F [:Incompatible_with] origin node 'A', it returned C and the node that was incompatible with A. Adding the new node :

match (g:Compound {id: '475') create (f:Drug {id: 'F'})-[CONTAINS]->(g);
match (f:Drug {id: 'F'}) match (a:Drug {id: 'A'}) create (f)-[:Incompatible_with]->(a)

Now when I run your query, I get back C, F, and B. I tried modifying the query with line 3:

MATCH (c:Drug)-[:Incompatible_with]->(d)
MATCH (o:Drug)-[r1:CONTAINS]->(g)<-[r2:CONTAINS]-(f)
WHERE <> AND = "A" and not (f)-[:Incompatible_with]-(o)
RETURN,, collect(r2.weight) as Weight ORDER BY Weight desc

But then I still get back C & B. I'd like to just get back B here