Gist

GraphX has never a huge success and was linked to RDD. GraphFrames is based on DataFrames and seems to take off. The scalability gives mixed results and if your graphs are below 100K edges you will have no issues, dealing with billions of links is however not so straightforward. At least, at this moment. By the time you read this things might be in version 1+ and soaring.

Things below are based on PySpark but things work just as easily with Scala. There are various articles explaining how to load GraphFrames in the context of Spark. It all amounts to something like

but with Spark and the ever-changing Apache landscape be prepared for some fiddling. Although I don’t want to advertise any particular service, I found that using Databricks is the easiest way to get going.

Import the namespace

and create some vertices via dataframes. For example

which can be combines into a graph:

Once you have a graph you can get all sorts of things out of it:

  • g.edges
  • g.degrees, g.inDegrees and g.outDegrees
  • counting filtered edges with g.edges.filter(“relationship = ‘follow'”).count()

Things like Microsoft’s CosmosDB uses Apache Gremlins, triples stores use SPARQL and Neo4J invented its own dialect. With GraphFrames you have motifs and it looks like this

or something which looks like an SQL where-clause:

Creating subgraphs goes via a subset of edges. For example, extracting the people who are friends an who are more than 30 years old:

Graph algorithms

GraphFrames comes with a number of standard graph algorithms built in:

  • Breadth-first search (BFS)
  • Connected components
  • Strongly connected components
  • Label Propagation Algorithm (LPA)
  • PageRank
  • Shortest paths
  • Triangle count

For instance, a breadth-first traversal starting from Esther for users of age less than 32:

The connected components are just as easy:

Something that in many applications (say, marketing) will be appreciated is the page rank:

giving something like

There are many more things you can (should) try out: triangle count, shortest paths (Dijkstra and such). Overall the framework feels ‘right’ and on the right track, unlike GraphX.

There are not many alternatives if you are looking for terabyte-size graphs. Apache Giraph is  an options and it seems Facebook is using it. Which says a lot:

 

Since its inception, Giraph has continued to evolve, allowing us to handle Facebook-scale production workloads  but also making it easier for users to program. In the meantime, a number of other graph processing engines emerged. For instance, the Spark framework, which has gained adoption as a platform for general data processing, offers a graph-oriented programming model and execution engine as well.

Some of the pro/con are summarized here. Though (large) graphs are everywhere it’s a bit surprising that big-graph framework are still so little used. There is some overlap with semantic (triple) stores and solutions like Neo4J, graph support in SQLServer 2017 on and alike but still. What works best is really a research on its own in function of data and (business) aims.