Neo4J是什么?

1. 一个高性能的图关系模型数据库
2. 一个NoSQL的数据库
3. 支持多种编程语言
4. Neo4J擅长处理具有多关系的模型数据
 
Neo4J中怎么删除与某个节点有关系的节点?
1. 查找到目标节点所有关系
2. 开启一个事务,删除所有关系的start node或end node
3. 遍历所有找到的node并删除相关的RelationShip
4. 然后删除node本身,提交事务
 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 }
在Neo4j中删除节点的本身有一个条件,就是这个节点没有任何的关系存在。

相关文章:

  • 2021-06-23
  • 2022-12-23
  • 2022-01-21
  • 2021-09-17
  • 2022-01-10
  • 2021-06-21
  • 2021-04-08
猜你喜欢
  • 2021-07-05
  • 2022-12-23
  • 2022-01-06
  • 2022-12-23
  • 2021-12-12
  • 2021-11-07
相关资源
相似解决方案