-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstance.java
More file actions
65 lines (50 loc) · 1.35 KB
/
Copy pathInstance.java
File metadata and controls
65 lines (50 loc) · 1.35 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package cph.instance;
import java.util.ArrayList;
import java.util.List;
public class Instance {
private int numHubs;
private int hubCapacity;
private int nodeData[][];
private List<Node> nodes;
private String name;
public Instance(String name, int numNodes, int numHubs, int hubCapacity, int[][] nodeData) {
this.name = name;
this.numHubs = numHubs;
this.hubCapacity = hubCapacity;
this.nodeData = nodeData;
nodes = new ArrayList<Node>();
for (int i = 0; i < numNodes; i++) {
nodes.add(new Node(i, this));
}
}
public Node getNode(int index) {
return nodes.get(index);
}
public int getX(int index) {
return nodeData[index][0];
}
public int getY(int index) {
return nodeData[index][1];
}
public int getDemand(int index) {
return nodeData[index][2];
}
public int getNumNodes() {
return nodes.size();
}
public int getNumHubs() {
return numHubs;
}
public int getHubCapacity() {
return hubCapacity;
}
public List<Node> getNodes() {
return nodes;
}
public String getName() {
return name;
}
public String getDescription() {
return name + " (n=" + getNumNodes() + ", p=" + numHubs + ", c=" + hubCapacity + ")";
}
}