Skip to content

Instantly share code, notes, and snippets.

@ruescasd
Created December 21, 2013 13:14
Show Gist options
  • Select an option

  • Save ruescasd/8069157 to your computer and use it in GitHub Desktop.

Select an option

Save ruescasd/8069157 to your computer and use it in GitHub Desktop.
(0 to questions-1).flatMap{ i =>
// calculate coverage of this question: we go through each vertex,
// and see if it has been assigned to answer to this question, or
// if a neighbour vertex (i.e. a delegate) has
vertexList.zipWithIndex.map{case(vertex, j) =>
if (assignments.get(j) == i) 1
else {
var incoming = graph.incomingEdgesOf(vertex)
incoming.map{edge =>
var src = edge.getPublicSrc
assignments.get(vertexList.indexOf(src)) == i
}.view.filter(_ == true).toSet.size
}
}
}.view.reduce(_ + _)/questions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment