routage-optimiste/structure/Router.java
2016-03-18 11:16:47 +01:00

38 lines
730 B
Java

package structure;
import java.util.ArrayList;
import java.util.HashMap;
public class Router {
private static int id=-1;
public String name;
private HashMap<Router,Integer> links=new HashMap<>();
public Router() {
// TODO Auto-generated constructor stub
id++;
this.name=""+id;
}
public void buildLink(Router router, int weight){
this.links.put(router, weight);
router.addLink(this, weight);
}
public void addLink(Router router, int weight){
this.links.put(router, weight);
}
public int getWeight(Router router){
return this.links.get(router);
}
public HashMap<Router, Integer> getLinks() {
return links;
}
public void setLinks(HashMap<Router, Integer> links) {
this.links = links;
}
}