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.

Reduce a graph

Hi,

I am wondering how to create a "reduced/collapsed" graph of the white graph below similar to the orange including relationships between the full graph and the reduced graph. I am not sure of the terms here but I think that the pictures might explain what I am after.

Screenshot 2022-12-08 at 11.23.11.png

I.e. I want to reduce nodes that are on the "same chain" (like a,b,c) to one node (like 1) to reduce complexity. Any recommendations on where I can look?

 

Cypher for the above structures: 

CREATE (k)<-[:_RELATED]-(j)<-[:_RELATED]-(i)<-[:_RELATED]-(c)-[:_RELATED]->(d)-[:_RELATED]->(g)-[:_RELATED]->(h)-[:_RELATED]->(f)<-[:_RELATED]-(e)<-[:_RELATED]-(k)-[:r]->(`6`),
(`2`)<-[:r]-(d)-[:_RELATED]->(e)-[:r]->(`3`),
(b)-[:r]->(`1`)<-[:r]-()-[:_RELATED]->(b)-[:_RELATED]->(c)-[:r]->(`1`),
(`3`)<-[:_RELATED]-(`6`)<-[:_RELATED]-(`1`)-[:_RELATED]->(`2`)-[:_RELATED]->(`3`)-[:_RELATED]->(`4`)<-[:_RELATED]-(`5`)<-[:r]-(g),
(`2`)-[:_RELATED]->(`5`)<-[:r]-(h),
(f)-[:r]->(`4`),
(i)-[:r]->(`6`)<-[:r]-(j)

 

1 REPLY 1

ameyasoft
Graph Maven

Use apoc.nodes.collapse procedure to merge nodes as desired.