27. Superhero Degrees of Seperation: Accumulators, and Implementing BFS in Spark
FRAMING BFS AS A SPARK PROBLEM
Implementing BFS In Spark
5983 1165 3836 4361 1282(5983, (1165, 3836, 4361, 1282), 9999, WHITE)
Map Function To Convert Marvel-Graph.txt To BFS Nodes
def convertToBFS(line: String): BFSNode = {
val fields = line.split("\\s+")
val heroID = fields(0).toInt
var connections: ArrayBuffer(Int) = ArrayBuffer()
for (connections <- 1 to (fields.length - 1)){
connections += fields(connection).toInt
}
var color: String = "WHITE"
var distance: Int = 9999
if (heroID == startCharacterID){
color = "GRAY"
distance = 0
}
}Iteratively Process The RDD
A BFS Iteration As A Map And Reduce Job
How Do We Know When We'Re Done?
Off To The Code
Previous26. Superhero Degrees of Seperation: Introducing Breadth-First SearchNext28. Superhero Degrees of Seperation: Review the code, and run it!
Last updated