Last active
August 29, 2015 14:08
-
-
Save treadstone90/b21bfd1a1b14d98c4709 to your computer and use it in GitHub Desktop.
Par Bottom up
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait ParallelAncestorManager { | |
def getAncestor(id: Int): ParSeq[Int] | |
def getParVertices: ParSeq[Int] | |
} | |
trait PBottomUpUpdater extends FrontierUpdater with ParallelAncestorManager { | |
def update(frontier: Seq[Int], parents: Array[Int]):Seq[Int] = { | |
val next = BitSet() | |
val frontierSet = frontier.toSet | |
getParVertices.filter(parents(_) == -1).foreach { node => | |
val parNeighbors = getAncestor(node) | |
parNeighbors.find(x => frontierSet.contains(x)) match { | |
case Some(ancestor) => { | |
parents(node) = ancestor | |
next(node) = true | |
} | |
case None => None | |
} | |
} | |
next.toBuffer | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment