In this present moment, Apache has develop a powerfull API called PySpark. And you can setup Graphframes directly from pyspark
command line. Launch from you shell terminal:
pyspark --packages graphframes:graphframes:0.6.0-spark2.3-s_2.11
and you can develop your code entirely in python
using graphframes
API. Try the following example code
# Create a Vertex DataFrame with unique ID column "id"
v = sqlContext.createDataFrame([
("a", "Alice", 34),
("b", "Bob", 36),
("c", "Charlie", 30),
], ["id", "name", "age"])
# Create an Edge DataFrame with "src" and "dst" columns
e = sqlContext.createDataFrame([
("a", "b", "friend"),
("b", "c", "follow"),
("c", "b", "follow"),
], ["src", "dst", "relationship"])
# Create a GraphFrame
from graphframes import *
g = GraphFrame(v, e)
# Query: Get in-degree of each vertex.
g.inDegrees.show()
# Query: Count the number of "follow" connections in the graph.
g.edges.filter("relationship = 'follow'").count()
# Run PageRank algorithm, and show results.
results = g.pageRank(resetProbability=0.01, maxIter=20)
results.vertices.select("id", "pagerank").show()
Above we could calculate pageRank
from graph g
. There are several algorithms already implemented on PySpark with Graphframes. I hope I've helped.