Skip to Main Content
Spark高级数据分析(第2版)
book

Spark高级数据分析(第2版)

by Sandy Ryza, Uri Laserson, Sean Owen, Josh Wills
June 2018
Beginner to intermediate content levelBeginner to intermediate
246 pages
6h 57m
Chinese
Posts & Telecom Press
Content preview from Spark高级数据分析(第2版)
GraphX
分析伴生网络
145
三角计数
三角形
是一个完备图,顶点
V
的三角计数就是包含该顶点的三角形的个数。
三角计数度量了
V
有多少个邻接点是相互连接的。
Watts
Strogatz
定义了一个新的指标,
称为
局部聚类系数
,它是一个顶点的实际三角计数与该顶点与其邻接点可能的三角计数的
比率。对无向图来说,有
k
个邻接点和
t
个三角计数的顶点,其局部聚类系数
C
为:
2
( 1)
t
C
k k
=
现在我们用
GraphX
来计算过滤后的概念图的每个节点的局部聚类系数。
GraphX
有一个
内置方法
triangleCount
,它返回一个
Graph
对象,其中
VertexRDD
包含了每个顶点的三
角计数。
val triCountGraph = interesting.triangleCount()
triCountGraph.vertices.map(x => x._2).stats()
...
(count: 14548, mean: 74.66, stdev: 295.33, max: 11023.0, min: 0.0)
要计算局部聚类系数,我们需要通过每个顶点可能的三角计数,对该顶点的三角计数进行
归一化。每个顶点可能的三角计数可以从
interestingDegrees
RDD
计算得出,代码如下:
val maxTrisGraph = interestingDegrees.mapValues(d => d * (d - 1) / 2.0)
现在我们要把
triCountGraph
中包含三角计数的
VertexRDD ...
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
管理Kubernetes

管理Kubernetes

Brendan Burns, Craig Tracey

Publisher Resources

ISBN: 9787115482525