Skip to content
Snippets Groups Projects
Unverified Commit 13006c56 authored by Hamza Remmal's avatar Hamza Remmal :homes:
Browse files

Add Parallel Graph Contraction example from lecture 3

parent 309a4148
No related branches found
No related tags found
No related merge requests found
package lecture3
import scala.collection._
import scala.collection.parallel.CollectionConverters.MapIsParallelizable
@main def parallelGraphContraction =
val graph = mutable.Map[Int, Int]() ++= (0 until 100000).map(i => (i, i+1))
graph(graph.size - 1) = 0
for((k, v) <- graph.par) graph(k) = graph(v)
val violation = graph.find {
case (i, v) => v != (i + 2) % graph.size
}
println(s"violation: $violation")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment