50. GraphX, Pregel, and Breadth-First-Search with Pregel.
Analyzing and transversing graphs
GRAPHX
Creating Vertex RDD's
// Function to extract hero ID -> hero name tuples (or None in case of failure)
def parseNames(line: String) : Option[(VertexId, String)] = {
var fields = line.split('\'")
if (fields.length > 1){
val heroID: Long = fields(0).trim().toLong
if (heroID < 6487) { // ID's above 6486 aren't real characters
return Some(fields(0).trim().toLong, fields(1))
}
}
return None // flatmap will just discard None results, and extract data from Some results.
}Creating Edge RDD's
Creating A Graph
Doing Stuff
Breadth-First Search With Pregel
How Pregel Works
BFS: Initialization
Sending Messages
Preserving The Minimum Distance At Each Step
Putting It All Together
Let's Do It
Last updated