Created
December 21, 2013 13:14
-
-
Save ruescasd/8069157 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| (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