Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- public class NodeApp {
- public static void main(String[] args) {
- Node[] nodes = new Node[200];
- for(int i=0; i<nodes.length; i++){
- nodes[i] = new Node(i, MyUtils.getClassification(), MyUtils.getMajor(), MyUtils.getMusic());
- }
- int[] vertices= new int[nodes.length];
- int [] edges= new int[vertices.length];
- for(int i=0; i<vertices.length; i++){
- int v = MyUtils.gen.nextInt(vertices.length);
- int w = MyUtils.gen.nextInt(nodes.length);
- while (v == w){
- w = MyUtils.gen.nextInt(vertices.length);
- }
- vertices[i] = v;
- edges[i] = w;
- }
- Graph G = new Graph(vertices,edges);
- for(int i=0; i<nodes.length; i++){
- System.out.println("-----------------");
- System.out.println(nodes[i]);
- System.out.println("Friends: ");
- for(Integer j: G.adj(i)){
- System.out.println(nodes[j] + " ");
- }
- }
- }
- }
- class MyUtils{
- static Random gen = new Random();
- public static void setSeed(long seed){
- gen = new Random(seed);
- }
- public static void print(Object[] array){
- for(Object obj: array){
- System.out.println(obj);
- }
- }
- public static Classification getClassification(){
- int n = gen.nextInt(4);
- Classification c;
- switch(n){
- case 0:
- c = Classification.Freshman; break;
- case 1:
- c = Classification.Sophmore; break;
- case 2:
- c = Classification.Junior; break;
- case 3:
- c = Classification.Senior; break;
- default:
- c = Classification.Freshman;
- }
- return c;
- }
- public static Major getMajor(){
- int n = gen.nextInt(6);
- Major major;
- switch(n){
- case 0:
- major= Major.Biology; break;
- case 1:
- major = Major.ComputerScience; break;
- case 2:
- major = Major.Psychology; break;
- case 4:
- major = Major.PoliticalScience; break;
- case 5:
- major=Major.Music;break;
- default:
- major = Major.Biology;
- }
- return major;
- }
- public static Music getMusic(){
- int n = gen.nextInt(6);
- Music music;
- switch(n){
- case 0:
- music = Music.Jazz; break;
- case 1:
- music = Music.Pop; break;
- case 2:
- music = Music.RnB; break;
- case 3:
- music = Music.Pop; break;
- case 4:
- music=Music.Rock;break;
- default:
- music= Music.other;
- }
- return music;
- }
- public static boolean check(Node x,Node y){
- if(x.classification==y.classification){
- return true;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement