【发布时间】:2018-12-11 05:23:21
【问题描述】:
考虑到一个有 14,000 个顶点和 14,000 条边的图,我想知道为什么 GraphX 比图的 java 实现花费更多的时间来获取从一个顶点到叶子的所有路径?
java 实现:几秒钟
Graphx 实现:几分钟
spark GraphX 真的适合这种处理吗?
我的系统: i5-7500 @3.40GHz, 8GB 内存
pregel 的算法:
val sourceId: VertexId = 42 // The ultimate source
// Initialize the graph such that all vertices except the root have canReach = false.
val initialGraph: Graph[Boolean, Double] = graph.mapVertices((id, _) => id == sourceId)
val sssp = initialGraph.pregel(false)(
(id, canReach, newCanReach) => canReach || newCanReach, // Vertex Program
triplet => { // Send Message
if (triplet.srcAttr && !triplet.dstAttr) {
Iterator((triplet.dstId, true))
} else {
Iterator.empty
}
},
(a, b) => a || b // Merge Message
【问题讨论】:
标签: java scala apache-spark spark-graphx