Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for merging virtual nodes / rels #653

Closed
tomasonjo opened this issue Nov 8, 2017 · 1 comment
Closed

add support for merging virtual nodes / rels #653

tomasonjo opened this issue Nov 8, 2017 · 1 comment

Comments

@tomasonjo
Copy link
Contributor

tomasonjo commented Nov 8, 2017

for now we can only create virtual nodes and it would be very helpyful if we could merge virtual nodes so that one can easily create a virtual graph.

CALL apoc.merge.vNode(['Label'], {key:value,…​}) YIELD node

Example use:

MATCH (h1:Hero)-[:KNOWS]->(h2:Hero)
WHERE h1.louvain <> h2.louvain
WITH h1.louvain as first,h2.louvain as second,count(*) as weight
call apoc.cypher.run("match (:`Hero`{louvain:"+first+"}) return count(*) as count", null) yield value 
CALL apoc.merge.vNode(['Cluster'], {community:first,size: value.count}) YIELD node as nodeFrom
CALL apoc.merge.vNode(['Cluster'], {community:second}) YIELD node as nodeTo
CALL apoc.create.vRelationship(nodeFrom,'COMMON',{weight:weight}, nodeTo) YIELD rel
RETURN nodeFrom,nodeTo,rel

Not sure if we want one parameter for merging only and one for ON CREATE SET,ON MATCH SET. In my example I don't need it

@vga91
Copy link
Collaborator

vga91 commented Feb 27, 2025

The above example with apoc.create.vNode instead of apoc.merge.vNode generates a correct virtual relationship.
Moveover, we can currently use the apoc.create.clonePathToVirtual and apoc.create.clonePathsToVirtual procedures to create virtual paths: https://neo4j.com/labs/apoc/4.3/overview/apoc.create/apoc.create.clonePathsToVirtual/ .
And to date, it looks more like a function regarding GDS.
I'm closing it, please reopen it if needed

@vga91 vga91 closed this as completed Feb 27, 2025
@github-project-automation github-project-automation bot moved this to Done (check 4.4 and 5.26 cherry-picks) in APOC Extended Larus Feb 27, 2025
@vga91 vga91 moved this from Done (check 4.4 and 5.26 cherry-picks) to Done in APOC Extended Larus Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

3 participants