cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Creating virtual node/rels from output of apoc.path.expand

mike
Graph Buddy

We have a db of UK companies and company officers, using apoc.path.expand:

MATCH (c:Company) where c.name = "REGULATION TECHNOLOGIES LTD"
call apoc.path.expandConfig(c, {maxLevel:4, relationshipFilter:'HAS_PERSON_RECORD|HAS_COMPANY|HAS_COMPANY_OFFICER', uniqueness:'RELATIONSHIP_GLOBAL'}) YIELD path
RETURN path

The final visualisation I want is orange node-blue node-orange node..., i.e. removing the grey node. (With help from the forum previously) made some progress using virtual relationships:

MATCH (c:Company) where c.name = "REGULATION TECHNOLOGIES LTD"
call apoc.path.expandConfig(c, {maxLevel:4, relationshipFilter:'HAS_PERSON_RECORD|HAS_COMPANY|HAS_COMPANY_OFFICER', uniqueness:'RELATIONSHIP_GLOBAL'}) YIELD path
UNWIND relationships(path) as rel
WITH DISTINCT rel
WITH startNode(rel) as event, collect(DISTINCT endNode(rel)) as toConnect
WITH toConnect[0] as toConnect1, toConnect[1] as toConnect2
CALL apoc.create.vRelationship(toConnect1,'CONNECTED_TO',{}, toConnect2) YIELD rel
RETURN toConnect1, rel, toConnect2

2X_6_64e0ca22ea85a017fa7781b70247f4ab9850ddad.png

The desired output is to have the blue nodes where the grey ones are. If it's a case of re-working the virtualisation step or some other step after it I have failed to crack it! Any help gratefully received.

Thanks

0 REPLIES 0