Skip to Content
数据分析之图算法: 基于Spark和Neo4j
book

数据分析之图算法: 基于Spark和Neo4j

by Mark Needham, Amy E. Hodler
September 2020
Intermediate to advanced
213 pages
5h 25m
Chinese
Posts & Telecom Press
Content preview from 数据分析之图算法: 基于Spark和Neo4j
路径查找算法和图搜索算法
43
该查询的返回结果如下所示:
place cost
Amsterdam 0.0
Immingham 369.0
Doncaster 443.0
London 720.0
4-6
显示了从
Amsterdam
London
的无权最短路径,该路线通过的城市最少,总代价
720
千米。
4-6Amsterdam London 之间的无权最短路径
对于地铁系统这样的应用场景,选择一条经过节点数最少的线路会非常有用,这是因为对
乘客搭乘而言,站点数量越少越好;然而在导航应用场景中,我们可能更关心最短加权路
径的总代价。
4.4.3
 使用
Neo4j
实现加权最短路径算法
可以执行加权最短路径算法查找
Amsterdam
London
之间的最短路径,如下所示:
MATCH
(source:Place {id: "Amsterdam"}),
(destination:Place {id: "London"})
CALL algo.shortestPath.stream(source, destination, "distance")
YIELD nodeId, cost
RETURN
algo.getNodeById(nodeId).id
AS
place, cost
传递给该算法的参数有以下
3
项。
source
最短路径搜索的起始节点。
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

大数据项目管理:从规划到实现

大数据项目管理:从规划到实现

Ted Malaska, Jonathan Seidman
Presto实战

Presto实战

Matt Fuller, Manfred Moser, Martin Traverso
精實企業|高績效組織如何達成創新規模化

精實企業|高績效組織如何達成創新規模化

Jez Humble, Joanne Molesky, Barry O'Reilly

Publisher Resources

ISBN: 9787115546678