@@ -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