Last active
February 18, 2018 21:48
-
-
Save Sciss/a1a6f769a29003c5d7b9b1696d162c82 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
// given the number of edges of a complete graph, | |
// determine the number of vertices. will be integer, | |
// if this is a complete graph. | |
// | |
// solves edges = vertices * (vertices - 1) / 2 | |
def vertices(edges: Int): Double = { | |
val q = -2 * edges | |
val ph = -0.5 | |
val phs = 0.25 | |
val r = math.sqrt(phs - q) | |
val x1 = -ph + r x1 | |
} | |
val ex = (1 to 200).flatMap { e => val v = vertices(e); val vi = v.toInt; if (v == vi) Some(e -> vi) else None } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment