Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit dab7eed

Browse files
committed
Getting closer
1 parent 1d76d47 commit dab7eed

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

dining.out

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,56 @@
44
1
55
1
66
1
7+
0
8+
0
79
1
810
1
911
1
1012
1
1113
1
1214
1
15+
0
16+
0
1317
1
1418
1
1519
1
1620
1
1721
1
1822
1
23+
0
24+
0
1925
1
2026
1
2127
1
2228
1
2329
1
2430
1
31+
0
32+
0
2533
1
2634
1
2735
1
2836
1
2937
1
3038
1
3139
1
40+
0
3241
1
3342
1
3443
1
3544
1
3645
1
3746
1
3847
1
48+
0
3949
1
4050
1
4151
1
4252
1
4353
1
4454
1
4555
1
46-
1
47-
1
48-
1
49-
1
50-
1
51-
1
52-
1
53-
1
54-
1
55-
1
56-
1
56+
0
5757
1
5858
1
5959
1

src/dining.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@ public static int[] dijkstra(int[][] graph1, int startVertex) {
4444

4545
int edgeDistance = graph1[nearestVertex][vertexIndex];
4646
// Used to be >
47-
if (edgeDistance != 0 && ((shortestDistance + edgeDistance) < dists[vertexIndex])) {
47+
if (edgeDistance > 0 && ((shortestDistance + edgeDistance) < dists[vertexIndex])) {
4848
parents[vertexIndex] = nearestVertex;
4949
dists[vertexIndex] = shortestDistance +
5050
edgeDistance;
5151

5252
}
5353
//if(pastures.contains(new IPair(nearestVertex,vertexIndex))) {
5454

55-
if(pastures.contains(nearestVertex) ) {
55+
//if(pastures.contains(nearestVertex) ) {
5656
System.out.println("Info: "+nearestVertex+" "+vertexIndex);
5757
System.out.println("Set "+(nearestVertex - 1) + " and "+(vertexIndex - 1));
58-
arr[nearestVertex] = 1;
59-
arr[vertexIndex] = 1;
58+
//arr[nearestVertex] = 1;
59+
//arr[vertexIndex] = 1;
6060
/*
6161
if(pasture[nearestVertex] > 0) {
6262
for(int j = 0; j < N; j++) {
@@ -71,9 +71,9 @@ public static int[] dijkstra(int[][] graph1, int startVertex) {
7171
}
7272
}
7373
*/
74-
graph1[nearestVertex][vertexIndex] = 0;
75-
graph1[vertexIndex][nearestVertex] = 0;
76-
}
74+
//graph1[nearestVertex][vertexIndex] = 0;
75+
//graph1[vertexIndex][nearestVertex] = 0;
76+
//}
7777
}
7878
}
7979
root = parents;
@@ -99,6 +99,7 @@ public static void main(String[] args) throws IOException{
9999
}
100100
//System.out.println(Arrays.deepToString(matrix).replaceAll("],*", "],\n"));
101101
// Dijkstra Modification begins here
102+
int[] out = dijkstra(matrix, N-2);
102103
for(int i = 0; i < K; i++) {
103104
st = new StringTokenizer(f.readLine());
104105
int x = Integer.parseInt(st.nextToken());
@@ -123,13 +124,18 @@ public static void main(String[] args) throws IOException{
123124
// End modification
124125
System.out.println("Modifacation Complete");
125126
System.out.println(Arrays.deepToString(matrix).replaceAll("],*", "],\n"));
126-
int[] out = dijkstra(matrix, N-1);
127+
int[] out2 = dijkstra(matrix, N-1);
128+
129+
//System.out.println(Arrays.toString(root));
130+
//System.out.println(Arrays.toString(out));
127131

128-
System.out.println(Arrays.toString(root));
129-
System.out.println(Arrays.toString(out));
130132
PrintWriter pw = new PrintWriter(new FileWriter("dining.out"));
131133
for(int k = 0; k < arr.length -1; k ++) {
132-
pw.println(arr[k]);
134+
if(out[k] <= out2[k]) {
135+
pw.println("1");
136+
}else {
137+
pw.println("0");
138+
}
133139
}
134140
pw.close();
135141

0 commit comments

Comments
 (0)