Replies: 2 comments 2 replies
-
Hi @pm-hwks: If you are inserting a single edge, say F -> C, before you insert the edge, you can check if C has a path to F. This would only work if you are inserting edges using CREATE/MERGE statements (so it would not work if you're doing bulk insertion). So in python you can do something like this (suppose con is a Connection object):
I am assuming your nodes have type N and edges have type R. I am sure I'm making syntax errors and the code above probably won't run/compile but it should give you the general idea. You can also not use transactions and just write a single query with CASE WHEN THEN clauses that achieves the same. |
Beta Was this translation helpful? Give feedback.
-
I wanna add some of my thoughts here too. A common way to detect cycles between two nodes is through the following statement
The above statement only checks 1 level edge. if the cycle can be deep, you may change Once a cycle is found, you can further decide if you wanna delete the forward or backward edge. |
Beta Was this translation helpful? Give feedback.
-
In manufacturing, it is typical to have multi level hierarchy of bill of materials to build / assemble products. Due to human error or other reason's some times cyclic relationships are entered in to the data. This cyclic relationships leads to several issue with BOM traversal and analytics.
How to detect and eliminate such cyclic relationships?
simple example : In the invalid tree, there is an edge from F to C which needs to be detected and deleted.
Beta Was this translation helpful? Give feedback.
All reactions