我试图使用pyspark使用Python运行Spark graphx.我的安装看起来是正确的,因为我能够运行pyspark教程和(Java)GraphX教程.大概是因为GraphX是Spark的一部分,pyspark应该能够与它接口,对吗?
以下是pyspark的教程:http ://spark.apache.org/docs/0.9.0/quick-start.html http://spark.apache.org/docs/0.9.0/python-programming-guide. HTML
以下是GraphX的内容:http : //spark.apache.org/docs/0.9.0/graphx-programming-guide.html http://ampcamp.berkeley.edu/big-data-mini-course/graph-分析与- graphx.html
任何人都可以将GraphX教程转换为Python吗?
我在spark站点上运行了单源最短路径(SSSP)示例,如下所示:
码(斯卡拉):
object Pregel_SSSP {
def main(args: Array[String]) {
val sc = new SparkContext("local", "Allen Pregel Test", System.getenv("SPARK_HOME"), SparkContext.jarOfClass(this.getClass))
// A graph with edge attributes containing distances
val graph: Graph[Int, 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.mapVertices((id, _) => if (id == sourceId) 0.0 else Double.PositiveInfinity)
val sssp = …Run Code Online (Sandbox Code Playgroud)