Loading Spark from file

Once we have the resulting graph, we can pass the spark and path parameters to our GraphBuilder.loadFromFile() method, and at this point, we'll have a graph that is a construct graph of Graph [Int, Int], as follows:

  val graph = GraphBuilder.loadFromFile(spark, path)

To iterate and validate that our graph was properly loaded, we will use triplets from graph, which are a pair of vertex to vertex and also an edge between those vertices. We will see that the structure of the graph was loaded properly:

    //then
graph.triplets.foreach(println(_))

At the end, we are asserting that we get 4 triplets (as shown earlier in the Creating the loader component section, we have four definitions from the graph.g file):

    assert(graph.triplets.count() == 4)
}

}

We will start the test and see whether we are able to load our graph properly.

We get the following output. Here, we have (2, 1), (3, 1), (3,1), (5,1), (1,1), (2,1), (1,1), and (3,1):

Hence, according to the output graph, we were able to reload our graph using Spark.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.54.136