diff options
| author | Loic Guegan <16000511@e003m10.istic.univ-rennes1.fr> | 2016-03-21 15:40:39 +0100 |
|---|---|---|
| committer | Loic Guegan <16000511@e003m10.istic.univ-rennes1.fr> | 2016-03-21 15:40:39 +0100 |
| commit | 9cb19346dadb23e81a89cec151d43aa5fa33dc15 (patch) | |
| tree | 299d7fb67ded798f75c7ff13122a8c141e7cbe3a /structure/Grid.java | |
| parent | 0676d16b3a5c13e2b75e97e7140b938b323cd79e (diff) | |
Ajout affichage meilleur chemin
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; } |
