Neo4j入门(三)删除关系
from py2neo import Graph, Node, Relationship
from py2neo import NodeMatcher, RelationshipMatcher
# 连接Neo4j
url = "http://localhost:7474"
username = "neo4j"
password = "12345678"
graph = Graph(url, auth=(username, password))
print("neo4j info: {}".format(str(graph)))
start_node = NodeMatcher(graph).match("Person", name="Alice").first()
end_node = NodeMatcher(graph).match("Person", name="Bob").first()
rel = RelationshipMatcher(graph).match([start_node, end_node], r_type="Knows").first()
print(rel)
graph.delete(rel)
neo4j info: Graph('http://neo4j@localhost:7474')
(Alice)-[:Knows {}]->(Bob)
from py2neo import Graph, Node, Relationship
from py2neo import NodeMatcher, RelationshipMatcher
# 连接Neo4j
url = "http://localhost:7474"
username = "neo4j"
password = "12345678"
graph = Graph(url, auth=(username, password))
print("neo4j info: {}".format(str(graph)))
start_node = NodeMatcher(graph).match("Person", name="Alice").first()
end_node = NodeMatcher(graph).match("Person", name="Bob").first()
rel = RelationshipMatcher(graph).match([start_node, end_node], r_type="Knows").first()
print(rel)
graph.separate(rel)
https://mp.weixin.qq.com/s?src=11×tamp=1640591254&ver=3521&signature=cwgohZDlz5oP8L3VMxVteqXBYqrCrTE9KoiiE9YaZ0Alfi9ImkpWs6of7zEK6R6bBGZ3AqMNPSUH4QfUSVt3puBku34fFVer4tb-uYl-5ZzB5SKPKH6yuzyFhqcH4eO*&new=1
相关文章