Help me with this Cypher Query

have a graph that contains nodes and relationships like what I draw in the picture, I want a collection of all cS nodes, but my CQL only returns one per line in text view, how can I get the result I need? ( I need something like [firstCS, secondCS, thirdCS])

MATCH (rD:d)-[:IHF]->(rK)-[:HC]->(cS:c)
WITH rD, cS
WITH rD, cS, SIZE( ()-[:HC]->(cS) ) AS Csum
RETURN rD.name, cS.name, Csum

couple of issues.

  1. your cypher describes a relation of [:HS] but yet your picture appears to have a relationship of :HC

  2. the usage if SIZE( ()-[:HS]->(cS) ) will report the number of :HS relationships from a given cS aliased node to any other node and from the picture :cS labeled nodes appear to have only 1 relationship.

  3. in the initial match is (rk), which basically says match a :d labeled not via a :IHF relationship to any other node (regardless of label). Should this instead be (rk:RK) or similar

So lets say you had

(:rD {id:rd1})-[:IHF]->(:RK)->[:HC]->(:c {id:'c1'})
(:rD {id:rd1})-[:IHF]->(:RK)->[:HC]->(:c {id:'c2'});

then WITH rD, cS, SIZE( ()-[:HS]->(cS) ) AS Csum is going to evaluate ti

(:rD {id:rd1}),   (:c {id:'c1'}),  1
(:rD {id:rd1}),   (:c {id:'c2'}), 1

Hi @maziar

I created the data.

CREATE (d:d {name: 'rd'})-[:IHF]->()-[:HS]->(:c {name: 'name1'}),
       (d)-[:IHF]->()-[:HS]->(:c {name: 'name2'}),
       (d)-[:IHF]->()-[:HS]->(:c {name: 'name3'})

I wrote this Cypher.

MATCH (rD:d)-[:IHF]->(rK)-[:HS]->(cS:c)
RETURN rD.name, collect(cS.name), count(cS.name) AS Csum

I think the return value is something like this.
Is this the answer to your question?

sorry @dana_canzano it was a typo mistake the relationship is HC, let me try your suggestion

Awesome @koji it seems it is working but let me include it in the main story and I will get back to you, thank you so much