Python Py2neo 创建关系耗时太长,只有 150k 关系

问题描述

我的数据存储在三元组列表中,节点已经插入到 neo4j 中。但是,在这些节点之间创建关系需要很长时间(仅 150k 关系需要 6 小时)。我在 python 中使用 Py2neo 库进行批量操作,但速度太慢。

这是我的数据:

enter image description here

这是我迄今为止尝试过的: create_relationships(graph.auto(),full_db,"HOP_TO",start_node_key("Technology","name","level"),end_node_key("Technology",keys=["cost"])

但这需要太长时间。我也试过这个:

//inserting relationships into graph
tx = graph.begin()
//between techs
for index,row in full_db.iterrows():
    node1 = graph.nodes.match("Technology",name=row['skill_from'],title=row['level']).first()
    node2= graph.nodes.match("Technology",name=row['skill_to'],title=row['level_to']).first() 
    try:
        tx.create(Relationship(node1,"HOP",node2,cost=row['cost']))
    except:
        continue
tx.commit() 

但它在 10 小时后仍在运行。 关于如何更快地获得它的任何提示?不使用 csv 加载器?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)