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

Add Parallel Graph Contraction with TrieMap example from lecture 3

parent 13006c56
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 parallelGraphContractionCorrect =
val graph = concurrent.TrieMap[Int, Int]() ++= (0 until 100000).map(i => (i, i+1))
graph(graph.size - 1) = 0
var previous = graph.snapshot()
for((k, v) <- graph.par) graph(k) = previous(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