from py2neo importGraph,Node,Relationship,NodeMatcher,RelationshipMatcher,PathclassMovie():'''电影'''
def __init__(self, id, name):
self.id=id
self.name=nameclassPerson():'''人'''
def __init__(self, id, name):
self.id=id
self.name=namedefinitNeo4j():'''初始化neo4j
:return:'''graph=Graph("http://127.0.0.1:7474",
username="neo4j",
password="123")returngraphdef get_person_actorof_movie(graph, p_id) ->list:'''查找演员参演的电影,并返回三元组
:param graph:
:param p_id:
:return:'''data= graph.run("match path=(m:Movie)-[:ACTOR_OF]->(p:Person)"
"where p.id = $id return relationships(path) as relationships",
id=p_id)
movieDict= {} #电影
personDict &