neo4j-labs / arrows.app

A graph drawing application
https://arrows.app
Apache License 2.0
107 stars 16 forks source link

Merge export in cypher #10

Closed Kingfelipe8 closed 3 years ago

Kingfelipe8 commented 3 years ago

Love your product! Had a small issue with the merge for a branching graph, the merge export produced "MERGE (:cheeses)<-[:Process]-(test:fruit)-[:CONSUME]->(:Veg), (test)-[:baaaagaaaah]->(:final)" which doesnt work in the neo4j browser, it looks like the , is the issue and replacing that with merge works fine. so the output would be "MERGE (:cheeses)<-[:Process]-(test:fruit)-[:CONSUME]->(:Veg) MERGE (test)-[:baaaagaaaah]->(:final)"

Kingfelipe8 commented 3 years ago

Also one further thought on the merge, if we are using your tool to draw a part of a processs and then want to add it to our existing neo database, the current merge code won't neccessarily work too well. This is because it will create a separate graph. You may want to think about adding an option which will split the query a bit so that if the nodes already exist we can start to link them up.

That would mean something like "MERGE (:Animal {colour: "Black and White"})-[:CONSUME]->(:Veg {colour: "Orange"})" would become "MERGE (badger:Animal {colour: "Black and White"}) MERGE (carrot:Veg {colour: "Orange"}) MERGE (badger)-[:CONSUME]->(carrot)"

That way if the nodes already exist in the database we can add the section we have designed in your tool. If you have any questions or this is unclear let me know.

ghost commented 3 years ago

@Kingfelipe8 The same issue as you. I don't know arrows.app if will update anymore, and also didn't know will open source it.

apcj commented 3 years ago

@Kingfelipe8 great that you like the tool, and thanks for your feedback!

There is indeed a problem with MERGE at the moment. Whatever the tool generates should be valid Cypher. We'll get this fixed. Thank you for the example.

Your other question about updating an existing database is also interesting. The current algorithm aims to make long paths; basically it picks a node and follows relationships until it can't go any further. That is good for some situations, but bad for others, as in your example. Possibly we'll add a choice of algorithms, one of which would emit the kind of cypher you are asking for.

apcj commented 3 years ago

Hi @Kingfelipe8 the latest version now emits valid cypher for MERGE. Please make sure you hard refresh or clear your cache to get the latest code.

This still doesn't solve the second part of your question, but I hope to add that as an enhancement soon.

Kingfelipe8 commented 3 years ago

Just checked it out and works great. I like your implementation, especially how it keeps a very tight merge statement on a highly interconnected graph and only splits merges when needed.

Yeah second part was very much a nice to have, but useful if you have multiple people trying to build up an overall shared view, good luck with it :-) .