-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.java
executable file
·91 lines (72 loc) · 2.13 KB
/
main.java
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedList;
import com.FlightMap.DestNode;
import com.FlightMap.SourceNode;
import com.FlightMap.FlightMap;
public class main{
public static void main(String[] args){
//Initialize values
String flightData = args[0];
//String arg2 = args[1];
//String arg3 = args[2];
BufferedReader br = null;
FileReader fr = null;
FlightMap flightMap = new FlightMap();
int srcNode = 0;
try{
fr = new FileReader(flightData);
br = new BufferedReader(fr);
String line = br.readLine();
int numLines = Integer.parseInt(line);
for(int i = 0; i < numLines; ++i){
line = br.readLine();
String[] result = line.split("\\|");
// for (int j = 0; j < 4; ++j){
// System.out.println(result[j]);
// }
String src = result[0];
String dst = result[1];
int cost = Integer.parseInt(result[2]);
int time = Integer.parseInt(result[3]);
flightMap.addFlight(src, dst, cost, time);
flightMap.addFlight(dst, src, cost, time);
}
}catch(IOException e){
}
int graph[][] = flightMap.toIntArray();
//input for paths to calc
BufferedReader buffread = null;
FileReader fileread = null;
String sourceData = args[1];
try{
fileread = new FileReader(sourceData);
buffread = new BufferedReader(fileread);
String line = buffread.readLine();
int numLines = Integer.parseInt(line);
//System.out.println(numLines);
for(int i = 0; i < numLines; ++i){
line = buffread.readLine();
String[] result = line.split("\\|");
String source = result[0];
String dest = result[1];
Boolean sortByTime = result[2].equalsIgnoreCase("T");
//flightMap.setFilter(sortByTime);
srcNode = flightMap.getIntValue(source);
PathFind letsgo = new PathFind(flightMap.getSize());
letsgo.setNames(flightMap.getNames());
if(!(srcNode < 0)){
letsgo.dijkstra(graph, srcNode);
}
// FlightMap.add(
}
}catch(IOException e){
}
}
// Change return time to Source Node
//public static SourceNode readPathInfo(String flightDataLine){
//}
public void output(){
}
}