neo4j 迅速查询子图

​​​​​1. 定义

        搜素子图的过程使用与路径扩展类似的方法从指定节点出发、沿着特定关系类型遍历,并返回能够到达的所有节点和关系。

        APOC提供两种搜素子图的过程:

        - subgraphNodes():仅返回可以到达的节点;

        - subgraphAll():返回节点和关系。

        与路径扩展过程expand和expandConfig不同的是,上述两个过程不返回所有的路径。

 

2. 应用

搜索子图的过程不会遍历所有可能的路径(即节点和边的所有可能序列),因此在执行效率和成本方面都优于路径扩展过程。适用的场景包括:

- 寻找节点的k-度邻居(k-nearest neighbours);

- 判断节点之间是否连通;

- 对图进行划分子图的操作。

 

合理使用  CALL apoc.path.subgraphNodes

MATCH (intopice:Intopiece) WHERE intopice.order_number = "待输入"

CALL apoc.path.subgraphNodes(intopice, {maxLevel:1}) YIELD node

return node.order_number as order_number ,node.into_state as into_state,node.roster_type as roster_type

----


MATCH (intopice:Intopiece) WHERE intopice.order_number = "待输入"

CALL apoc.path.subgraphNodes(intopice, {maxLevel:2}) YIELD node

return node.order_number as order_number ,node.into_state as into_state,node.roster_type as roster_type

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值