Neo4j 加权交互

Neo4j Weighted Interactions

我有一个很大的 CSV 文件,看起来像

Node1    Node2    Weight
1         2         10 
2         3         15
1         3         5
3         10        20
etc...

我想在 Neo4j 上创建一个图表,显示节点 1 和节点 2 之间的交互,按权重列加权。

多亏了这个 post How to create unique nodes and relationships by csv file imported in neo4j?

我创造了互动

但是我还没有配重

我尝试了以下

USING PERIODIC COMMIT 500
LOAD CSV WITH HEADERS FROM "file:///ewqrwqsa.csv" AS line
MERGE (n:A {number : line.Node1})
WITH line, n
MERGE (m:B {ID : line.Node2})
WITH line, m, n 
MERGE (l:W {weight : toInteger(line.Weight)})
WITH l,m,n
MERGE (n)-[:Related(l)]->(m);

但是没用... 谢谢!

您似乎在尝试为关系添加 属性。试试这个:

USING PERIODIC COMMIT 500
LOAD CSV WITH HEADERS FROM "file:///ewqrwqsa.csv" AS line
MERGE (n:A {number : line.Node1})
MERGE (m:B {ID : line.Node2})
MERGE (n)-[r:Related]->(m)
SET r.weight = toInteger(line.Weight);