diff options
Diffstat (limited to 'structure/Grid.java')
| -rw-r--r-- | structure/Grid.java | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/structure/Grid.java b/structure/Grid.java index eb76638..bd0af2a 100644 --- a/structure/Grid.java +++ b/structure/Grid.java @@ -131,7 +131,7 @@ public class Grid { return currentBestLink; } - private int getMaxBottleneck(ArrayList<Integer> link){ + /*private int getMaxBottleneck(ArrayList<Integer> link){ int max=this.getWeigthOfLink(link.get(0), link.get(1)); for(int j=1;j<link.size()-1;j++){ int currentMax=this.getWeigthOfLink(link.get(j), link.get(j+1)); @@ -141,6 +141,17 @@ public class Grid { } return max; + }*/ + private int getMaxBottleneck(ArrayList<Integer> link){ + int max=this.getWeigthOfLink(link.get(0), link.get(1)); + for(int j=1;j<link.size()-1;j++){ + int currentMax=this.getWeigthOfLink(link.get(j), link.get(j+1)); + if(max>currentMax){ + max=currentMax; + } + + } + return max; } private int getWeigthOfLink(int router1,int router2){ @@ -153,14 +164,46 @@ public class Grid { ArrayList<Integer> link=this.links.get(i); System.out.print("Link number " + i + " ==> "); for(int j=0;j<link.size()-1;j++){ - //System.out.print(this.getWeigthOfLink(link.get(j), link.get(j+1)) + " "); + System.out.print(this.getWeigthOfLink(link.get(j), link.get(j+1)) + " "); } - System.out.println(this.getMaxBottleneck(link)); + System.out.println(" Goulot :"+this.getMaxBottleneck(link)); //System.out.println(); } } + + + public boolean isEdgeOfLink(ArrayList<Integer>link, Router src, Router dest){ + for(int j=0;j<link.size()-1;j++){ + Router current=this.grid.get(link.get(j)); + if(src.name.equals(current.name)){ + if(j<link.size()-1){ + Router currentDest=this.grid.get(link.get(j+1)); + + if(currentDest.name.equals(dest.name)){ + return true; + } + } + } + } + for(int j=0;j<link.size()-1;j++){ + Router current=this.grid.get(link.get(j)); + if(dest.name.equals(current.name)){ + if(j<link.size()-1){ + Router currentDest=this.grid.get(link.get(j+1)); + + if(currentDest.name.equals(src.name)){ + return true; + } + } + } + } + return false; + } + + + public ArrayList<Router> getGrid() { return grid; } |
