package org.apache.spark.graphx.algorithms
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("lm-shotestpath").setMaster("local[*]")
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.vertices.foreach(println)
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