-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.java
More file actions
51 lines (45 loc) · 1.5 KB
/
Node.java
File metadata and controls
51 lines (45 loc) · 1.5 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
import java.io.*;
import java.awt.*;
import java.applet.*;
import java.net.*;
import java.util.*;
import java.lang.*;
public class Node {
public int id;
public int numAuto;
public int numOppo;
public int currentOppo;
final static int option_number = 4; //number of shortest path stored at nodes;
final static int path_info_attributes = 2;
final static int large = 50; //the largest number of nodes on each path;
final static int nullindicator = -9;
final static int infinite = 999;
public int path[][][]; //Record the shortest path from ith node to current node;
//first bracket: from node index: nodeid-1;
//second bracket: nth shortest path; start from 3 options;
//third bracket: store each nodeid on the path;
public double path_info[][][];
//first bracket: from node index: nodeid-1;
//second bracket: nth shortest path; start from 3 options;
//thir bracket:
//0: number of nodes on path including origin and destination;
//1: total cost;
public Node(int id, int numNodes, int numAuto, int numOppo, int currentOppo){
this.id = id;
this.numAuto = numAuto;
this.numOppo = numOppo;
this.currentOppo = currentOppo;
this.path = new int[numNodes][option_number][large];
this.path_info = new double[numNodes][option_number][path_info_attributes];
for (int i=0;i<numNodes;i++){
for (int j=0;j<option_number;j++){
path[i][j][0] = id;
for (int k=1;k<large;k++){
path[i][j][k] = nullindicator;
}
path_info[i][j][0] = 1;
path_info[i][j][1] = infinite;
}
}
}
}