How do I collect all of the nodes in a subgraph

Try this:

MERGE (a1:Test {label: "A"})
MERGE (a2:Test1 {label: "B"})
MERGE (a3:Test2 {label: "C"})
MERGE (a4:Test3 {label: "D"})
MERGE (a5:Test4 {label: "E"})
MERGE (a6:Test5 {label: "F"})
MERGE (a7:Test6 {label: "G"})
MERGE (a8:Test7 {label: "H"})

MERGE (a1)-[:CONNECTS]->(a2)
MERGE (a2)-[:CONNECTS]->(a3)
MERGE (a2)-[:CONNECTS]->(a5)

MERGE (a3)-[:CONNECTS]->(a6)
MERGE (a3)-[:CONNECTS]->(a8)

MERGE (a1)-[:CONNECTS]->(a4)
MERGE (a4)-[:CONNECTS]->(a7)

RETURN *

Result:
Screen Shot 2020-10-17 at 4.39.47 PM

//relationshipFilter......

MATCH (a:Test1)
CALL apoc.path.subgraphNodes(a, {relationshipFilter:'CONNECTS>'}) 
YIELD node
RETURN node


//labelFilter......

MATCH (a:Test1)
CALL apoc.path.subgraphNodes(a, {labelFilter:'-Test'}) 
YIELD node
RETURN node

Both produce same results.

Screen Shot 2020-10-17 at 4.40.42 PM