Getting started with the GraphX API
In this section, we will create a graph using the GraphX
API. Here we will first create vertex and edge RDDs and then we will use them to create the graph.
Note
As of Spark 2.1.x, the GraphX
library only provides a stable Scala API. The Java API of GraphX is still in ALPHA version. In this chapter, we will call Scala APIs of GraphX in Java wherever required to perform the graph operations provided in the GraphX
library.
Let's start with creating a graph using the example provided in the previous section. The following are the ways of creating the graph.
Using vertex and edge RDDs
- First we define the vertex and edge RDD as follows:
List<Tuple2<Object, string>> vertices = new ArrayList<>(); vertices.add(new Tuple2<Object, string>(1l, "James")); vertices.add(new Tuple2<Object, string>(2l, "Robert")); vertices.add(new Tuple2<Object, string>(3l, "Charlie")); vertices.add(new Tuple2<Object, string>(4l, "Roger")); vertices...