create
(qiao:Person{name:"qiao"}),
(wang:Person{name:"wang"}),
(zhao:Person{name:"zhao"}),
(liang:Person{name:"liang"}),
(desk:Desk{num:123456}),
(qiao)-[:has_desk]->(desk),
(wang)-[:has_desk]->(desk),
(zhao)-[:has_desk]->(desk),
(zhao)-[:Friends{relation:"friend"}]->(qiao),
(zhao)-[:Friends{relation:"friend"}]->(liang)
1.共享信息
match(p1:Person)-[:has_desk]->(desk)<-[:has_desk]-(p2:Person)
where exists(desk.num)
with p1,p2
merge (p1)-[:Know{relation:"know"}]->(p2)
2.原有关系
match(p1:Person)-[r1:Friends{relation:"friend"}]->(p2:Person)
where exists(r1.relation)
with p1,p2
merge (p1)-[r2:Know{relation:"know"}]->(p2)
3.获取所需关系图
match m=(p1:Person)-[:Know{relation:"know"}]->(p2:Person) return m