如果他们有相同的朋友,我想表示 人可能会知道 人的图表路径。 当我运行这个查询时,我得到了我想要的表模式结果。
MATCH (p1:Person)-[:IS_FRIEND_OF]->(any:Person)
MATCH (p2:Person)-[:IS_FRIEND_OF]->(any)
WHERE NOT p1 = p2
RETURN p1, p2
我的问题是我想将它们表示为图形,并且连接person1和person2的关系将其重命名为" MAY_KNOWS "
答案 0 :(得分:1)
您可以在APOC中使用virtual relationships
:
MATCH (n:Person)-[r:IS_FRIEND_OF]->(other)
MATCH (other)-[:IS_FRIEND_OF]->(candidate)
WHERE NOT (n)-[:IS_FRIEND_OF]->(candidate)
RETURN n, other, candidate, apoc.create.vRelationship(n, 'MAY_KNOW', {}, candidate)
参考:https://neo4j-contrib.github.io/neo4j-apoc-procedures/#_virtual_nodes_rels