diff --git a/main/Main.java b/main/Main.java index df6ebd3..cad6995 100644 --- a/main/Main.java +++ b/main/Main.java @@ -6,7 +6,7 @@ public class Main { public static void main(String[] args) { Grid g=new Grid(); - - g.printGrid(); + g.printLinkWeight(); + System.out.println("Best link : " + g.getBestLinkIndex()); } } diff --git a/structure/Grid.java b/structure/Grid.java index 042d41c..c7b1211 100644 --- a/structure/Grid.java +++ b/structure/Grid.java @@ -15,6 +15,8 @@ public class Grid { private Random rand = new Random(); + private static final int maxWeight=100; + /** * Build a 3x3 Grid */ @@ -49,6 +51,7 @@ public class Grid { this.buildLinkWithRandomWeight(grid.get(2), grid.get(5)); this.buildLinkWithRandomWeight(grid.get(5), grid.get(8)); + this.buildLinks(); } @@ -112,11 +115,54 @@ public class Grid { private void buildLinkWithRandomWeight(Router router1, Router router2){ - router1.buildLink(router2, rand.nextInt(50)); + router1.buildLink(router2, rand.nextInt(this.maxWeight)); } + public int getBestLinkIndex(){ + int currentBestLink=0; + int currentBestLinkBottleneck=0; + for(int i=0;i currentLink=this.links.get(i); + int currentLinkBottleneck=this.getMaxBottleneck(currentLink); + if(currentBestLinkBottleneck link){ + int max=this.getWeigthOfLink(link.get(0), link.get(1)); + for(int j=1;j link=this.links.get(i); + System.out.print("Link number " + i + " ==> "); + for(int j=0;j