Created
September 4, 2012 02:24
-
-
Save sbstp/3615846 to your computer and use it in GitHub Desktop.
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
int sommets = rand(8, 12); | |
int arretes = rand(sommets, 2 * (fact(sommets) / (fact(2) * fact(sommets - 2)))); | |
GrapheOriente go = new GrapheOriente(sommets); | |
for (int i = 0; i < arretes; i++) { | |
int sommet1; | |
int sommet2; | |
do { | |
sommet1 = rand(1, sommets); | |
sommet2 = rand(1, sommets); | |
} while (sommet1 == sommet2 || go.sontAdjacents(sommet1, sommet2)); | |
go.ajouterArrete(sommet1, sommet2); | |
} | |
// ... | |
private static int rand(int min, int max) { | |
return new Random(System.nanoTime()).nextInt(max - min) + min; | |
} | |
private static int fact(int num) { | |
return (num == 1) ? 1 : num * fact(num - 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment