// 读取CSV文件并创建节点 LOAD CSV WITH HEADERS FROM 'file:///coauthors.csv' AS row WITH split(row.CoAuthors, ';') AS author_names UNWIND author_names AS author_name MERGE (a:Author {name: author_name})
// 建立每行作者之间的合作关系 WITH author_names UNWIND range(0, size(author_names)-1) AS i UNWIND range(i+1, size(author_names)-1) AS j WITH i, j, author_names MATCH (a1:Author {name: author_names[i]}) MATCH (a2:Author {name: author_names[j]}) MERGE (a1)-[:CO_AUTHOR]->(a2) MERGE (a2)-[:CO_AUTHOR]->(a1)
1 2 3 4
LOAD CSV WITH HEADERS FROM 'file:///ten.csv' AS row MERGE (a1:Author {name: row.author1}) MERGE (a2:Author {name: row.author2}) MERGE (a1)-[r:COLLABORATES_WITH {count: row.count}]->(a2)