Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-09-2022 09:13 PM
I want to use neo4j to handle such a scenario: for example, I have a set of interrelated nodes,These nodes form a tree structure. These nodes have two types of labels A and B. How can I achieve that A labeled nodes can only appear at the end of the path, but not in the path. The node with label B can appear anywhere in the path.
Thank you very much!
11-10-2022 03:11 AM
In other words, this is a loop traversal problem. The breadth traversal algorithm is used. When a node with a specified label is encountered, it skips over without traversing.
11-10-2022 06:55 AM
I am sorry I am having difficulties understanding what you need. Can you explain what your question better?
11-10-2022 08:54 PM
I am Sorry, my English is very poor. There is a graph containing multiple association relationships. I want to do sub graph mining. Assume that the relationship is r1, r2, r3. I only focus on r1 and r2, not on r3. However, there may be such situations, such as nodes A, B, C, D, and E, where A and B are r1, B and E are r3, A and C are r3, and C and D are r2. In this case, I need to preserve only the subgraphs of nodes A, B, C, and D.
11-11-2022 04:56 AM
What is special about node E that determines you want to delete the r3? Why not the r3 relationship between nodes A and C? Is this because mode E is a terminal node?
hiw does this relate to your original post about nodes labeled A or B, and A labeled nodes can only be a terminal node of a tree?
11-12-2022 09:06 PM
First of all, thank you very much for your reply.
1. My goal is to mine subgraphs, not delete any relationships.
2. The initial post was that I did not express clearly, and the following statement shall prevail.
3. In the example,
The sub graph I want finally only contains nodes A, B, C and D, not E,
Because the relationship between E and B is r3, and E is the terminal node of a tree.
Thank you very much!
11-12-2022 09:49 PM
Add and correct one point. In the following diagram,
Nodes A, C, and E are all nodes labeled A at the beginning,
B. D is the node labeled B at the beginning.
In fact, this may require deep traversal of all paths first,
If a path starts from a node and then does not contain the relationship I am concerned about,
Then this node is the terminal node of this path.
11-13-2022 09:33 AM
So, is this more of an issue of figuring out how to traverse paths in a graph to find subgraphs with certain constraints, versus understanding how to delete specific relationships? It now seems like you are looking for help with the former. Cypher is not very good for this purpose. You may want to look at the APOC path procedures. Specifically, apoc.path.expandConfig may help. You can specify constraints on the types of nodes and relationships you want/don't want.
https://neo4j.com/labs/apoc/4.4/overview/apoc.path/
Is this what you are looking for?
11-15-2022 02:18 AM
Thank you very much!
I did use apoc.path.expandConfig for this project.
However,It seems that we haven't found how to set parameters to meet the requirements.
All the sessions of the conference are now available online