Path expand and Virtual relationships


I'm looking for a way to use apoc.create.vRelationship on apoc.path.subgraphAll results.

For example, lets take the same data from documentation about subgraphAll:
The following returns the subgraph reachable by the KNOWS relationship at 1 to 2 hops from Praveena.

MATCH (p:Person {name: "Praveena"})
CALL apoc.path.subgraphAll(p, {
    relationshipFilter: "KNOWS",
    minLevel: 1,
    maxLevel: 2
YIELD nodes, relationships
RETURN nodes, relationships;


If from some reason Zhen had several relationships to Martin and I wanted to aggregate them into one using apoc.create.vRelationship, how can I specify the "from node" and "to node" parameters for the function from the "YIELD nodes, relationships"?

And more generally, for any given result from apoc.path.subgraphAll, how can I use vRelationship function to aggregate relationships for specified source and target node labels?



  • Neo4j 3.5
  • APOC

I know it has been three years since this post. But have you figured out a way to approach this? I have similar question on it as well.