aboutsummaryrefslogtreecommitdiff
path: root/structure/Router.java
blob: d9774719368e6c8eb91542cda9519789006b9e2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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;
	}
}