Neo4j - 如何显示连接到相关节点属性的节点图
Neo4j - How to display a graph of Nodes connected to properties of related nodes
我有节点 Customer 和 Product - 具有从 Customer 到 Product 的定向关系 TRANSACTION。
产品具有 属性 category
.
是否可以显示与他们购买的所有类别相关联的所有客户?就好像类别是一个节点而不是 属性.
您可以使用APOC Virtual Nodes and Relationships来显示这样的图表:
MATCH (n:Product)<-[:TRANSACTION]-(c:Customer)
WITH n.category AS category, c, count(*) AS numberOfPurchases
WITH
apoc.create.vNode(['Category'], {name: category}) AS catNode,
c,
numberOfPurchases
RETURN catNode, c,
apoc.create.vRelationship(c, 'PURCHASED_IN_CATEGORY', {amount: numberOfPurchases}, catNode) AS rel
我有节点 Customer 和 Product - 具有从 Customer 到 Product 的定向关系 TRANSACTION。
产品具有 属性 category
.
是否可以显示与他们购买的所有类别相关联的所有客户?就好像类别是一个节点而不是 属性.
您可以使用APOC Virtual Nodes and Relationships来显示这样的图表:
MATCH (n:Product)<-[:TRANSACTION]-(c:Customer)
WITH n.category AS category, c, count(*) AS numberOfPurchases
WITH
apoc.create.vNode(['Category'], {name: category}) AS catNode,
c,
numberOfPurchases
RETURN catNode, c,
apoc.create.vRelationship(c, 'PURCHASED_IN_CATEGORY', {amount: numberOfPurchases}, catNode) AS rel