What is neo4j?
1. A high-performance graph relational model database 2. A nosql database 3. multiple types of support Programming Language 4. How can I delete nodes related to a node in neo4j, which is good at processing model data with multiple relationships? 1. Find all links of the target node 2. Start a transaction, delete the Start Node or end node3. traverse all the nodes found and delete the relevant relationship4. then delete the node itself and submit a transaction.
1 Public Static Void Deleterelativenode (node N ){
2 Traversaldescription TD = traversal. Description (). Relationships (types. Relative, direction. Both)
3 . Evaluator (evaluators. excludestartposition ());
4 Traverser T = TD. Traverse (N );
5 For (Node TN: T. nodes ()){
6 Iterable <relationship> relationships = tn. getrelationships ();
7 For (Relationship R: Relationships ){
8 If (R. getstartnode (). Equals (n) | r. getendnode (). Equals (N )){
9 R. Delete ();
10 }
11 }
12 If (! Tn. hasrelationship ()){
13 Tn. Delete ();
14 }
15 }
16 }
A condition for deleting a node in neo4j is that the node does not have any relationship.