I have a Neo4j database comprising Film
and Person
nodes connected by ACTED_IN
relationships. Using APOC, I've managed to create a set of virtual ACTED_WITH
relationships directly between Person
nodes reflecting the fact that they're indirectly related through a Film
in which they both appeared:
MATCH (a:Person)-[:ACTED_IN]->()<-[:ACTED_IN]-(b:Person)
WITH a, b
CALL apoc.create.vRelationship(a, 'ACTED_WITH', {}, b) YIELD rel
RETURN a, rel, b
This seems to capture the indirect relationship I'm looking for. Now I want to stream the results of this to Gephi for visualisation. But the relevant APOC function takes a paths
argument. So this works:
MATCH path = ()-[:ACTED_IN]->()
WITH collect(path) AS paths
CALL apoc.gephi.add(null, 'workspace0', paths) YIELD nodes, relationships, time
RETURN nodes, relationships, time
How can I create a set of paths from the virtual relationships yielded in the first code block for passing to Gephi as in the second? (Or is there a better way to deal with this kind of case?)