老外论坛找到一个最短路径和中间节点的算法
import org.apache.spark.{SparkConf, SparkContext} import org.apache.spark.graphx.{EdgeDirection, VertexId, Graph} import org.apache.spark.graphx.util.GraphGenerators object Pregel_SSSP { def main(args: Array[String]) { val conf = new SparkConf().setAppName("Pregel_SSSP") val sc = new SparkContext(conf) // A graph with edge attributes containing distances val graph: Graph[Long, Double] = GraphGenerators.logNormalGraph(sc, numVertices = 5).mapEdges(e => e.attr.toDouble) graph.edges.foreach(println) val sourceId: VertexId = 0 // The ultimate source // Initialize the graph such that all vertices except the root have distance infinity. val initialGraph : Graph[(Double, List[VertexId]), Double] = graph.mapVertices((id, _) => if (id == sourceId) (0.0, List[VertexId](sourceId)) else (Double.PositiveInfinity, List[VertexId]())) val sssp = initialGraph.pregel((Double.PositiveInfinity, List[VertexId]()), Int.MaxValue, EdgeDirection.Out)( // Vertex Program (id, dist, newDist) => if (dist._1 < newDist._1) dist else newDist, // Send Message triplet => { if (triplet.srcAttr._1 < triplet.dstAttr._1 - triplet.attr ) { Iterator((triplet.dstId, (triplet.srcAttr._1 + triplet.attr , triplet.srcAttr._2 :+ triplet.dstId))) } else { Iterator.empty } }, //Merge Message (a, b) => if (a._1 < b._1) a else b) println(sssp.vertices.collect.mkString("\n")) } }
相关推荐
spark graphX实战 中英文两版 spark graphX实战 中英文两版
A lot of companies, including the ones we work for and have worked for in the past, have put Spark—though not necessarily GraphX—into production. This makes it more than just a little convenient ...
spark graphx基础操作文档。。。。。。。。。。。。
Spark-GraphX框架下的大规模加权图最短路径查询
Spark GraphX In Action.pdf 高清 带索引目录数据,图形计算
Spark GraphX in Action 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn...
spark-graphx实现中文及英文pdf版本电子书。详细地讲解了GraphX的方方面面,并且还介绍了scala和spark的各个知识点,从spark基础知识、scala基础知识、图基础知识开始讲解,是一本很好的GraphX入门书籍
Spark GraphX源码分析 Spark 大数据框架的 GraphX 子框架 大数据、图计算,源码分析书
本书详细介绍如何利用Spark Graph组件进行图计算,并依托项目背景,对Spark图计算进行深入研究,适合Spark爱好者进行阅读
关于spark graphx的介绍,上课用讲义,英文版本,通过讲义,可以了解spark graphx
基于Spark-Graphx的大规模用户图计算和应用 完整高清 基于Spark-Graphx的大规模用户图计算和应用 完整高清
spark-graphx_2.11-2.4.0-cdh6.1.1.jar
Spark_GraphX大规模图计算和图挖掘
spark graphx google用于网页排名计算的拓扑图状关系数据结构
介绍Spark GraphX 的书籍不多,这是一本专门详细讲解GraphX 的书籍
Spark.GraphX.in.Action.2016.6.pdf
spark-graphx_2.11-2.1.3-SNAPSHOT.jar
预凝胶最短路径 Pregel 系统的最短路径算法。 使用 Apache Spark 和 GraphX API 实现。 Scala
Spark GraphX in Action starts out with an overview of Apache Spark and the GraphX graph processing API. This example-based tutorial then teaches you how to configure GraphX and how to use it ...
Spark GraphX基本操作