cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Need cypher a query

I am new to neo4j can you please help to write a cypher query for the following subgraph. We are using neo4j.3.5.x version.

A--->next--->S1<----Has-----S
A--->.next---->S2<-----Has----S
B--->next--->T1<----Has-----T
B--->next--->T2<----Has-----T
B--->.next---->M1<-----Has----M

I need B node because which connected differnt END nodes T,M.

1 ACCEPTED SOLUTION

Hello @rayapatir4

A request in the same style could do the job (you can add a Label to nodes):

MATCH (a)-[:NEXT]->()<-[:HAS_INSTANCE]-(c)
WITH a, count(DISTINCT c) AS nb_nodes
WHERE nb_nodes >= 2
RETURN a

Regards,
Cobra

View solution in original post

5 REPLIES 5

rushikesh
Node Clone

@rayapatir4, do you want to create a graph or you want to search node B?

I need find query.I need B node as it participated in 2 different end nodes T,M
2X_4_465628f7bf40292efd8f7586274eb0ae8ca8d707.png
2X_1_126be32980dc66b274654f40b7bf4330e177b0bd.png

Hello @rayapatir4

A request in the same style could do the job (you can add a Label to nodes):

MATCH (a)-[:NEXT]->()<-[:HAS_INSTANCE]-(c)
WITH a, count(DISTINCT c) AS nb_nodes
WHERE nb_nodes >= 2
RETURN a

Regards,
Cobra

@Cobra,

Thank you for your quick help. Its working as expected.

No problem 🙂 I'm happy to hear it