I have a graph representation of data with multiple nodes with random relationships
I'm using Neo4j to represent this and using query Using query
MATCH (a)-[r]->(b)-[r2]->(c)
I'm getting an output where ever A is related with B and B is related with C
But I need to query nodes A and B with any relationship (call as RelationA) and all C following B (with RelationA) with the Same relation as A and B like the following image
if A is connected with more than one B then the expected graph will be like this
You can check the equality of the relationships in the WHERE
clause.
MATCH path=(a)-[r]->(b)-[r2]->(c)
WHERE type(r)=type(r2)
RETURN path
P.S.: If you are viewing this result in the Neo4j browser, then it "connects the result nodes" which means it adds extra relationships between nodes that don’t match the criteria. Don’t forget to uncheck the "connect result nodes" option in the from the settings.