Split list into two sets based on node type

How can I split the nodes list returned from apoc.path.subgraphAll into two distinct sets based on the node type?

MATCH (l)
CALL apoc.path.subgraphAll(l, {
	relationshipFilter: "follows", "isFriendsWith"
})
YIELD nodes

WITH [n in nodes WHERE n:Type1] as n1
     [n in nodes WHERE n:Type2] as n2
UNWIND n1 as x1
UNWIND n2 as x2
RETURN x1.propA, x2.propB

Your use of list comprehension to create the nodes into two lists based on node’s label is a good approach.

What is wrong with your results?

Note, your code is missing a comma between the two list comprehension operations in the “with” clause.

It seems like it is not working on the nodes returned from the apoc.path.subgraphAll, but instead on all available nodes in the database. I get back 30,000 records instead of 150.

Well, you Re calling the subgrapg procedure for every node in your grapgh, since your match has no constraints.