Skip to content

Commit 9d7e5ba

Browse files
authored
added comments Dijkstra.java #1
1 parent 3c68670 commit 9d7e5ba

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Dijkstra.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/*
2+
this program is used to find minimum distance between two vertices while traversing all available vertices.
3+
*/
14
package javacodes;
25

36
import java.util.*;
@@ -49,7 +52,7 @@ void dijkstra(int graph[][], int src)
4952
}
5053

5154

52-
dist[src] = 0;
55+
dist[src] = 0; /* Starting distance is zero */
5356

5457

5558
for (int count = 0; count < V-1; count++)
@@ -83,7 +86,7 @@ public static void main (String[] args)
8386
{
8487
Scanner in=new Scanner(System.in);
8588

86-
System.out.println("Number of vertices:");
89+
System.out.println("Number of vertices:"); /* print the total numbers of vertices */
8790

8891
V=in.nextInt();
8992

@@ -97,7 +100,7 @@ public static void main (String[] args)
97100

98101
graph[i][j]=in.nextInt();
99102
}
100-
Dijkstra ob=new Dijkstra();
103+
Dijkstra ob=new Dijkstra(); /* create new object of Dijkstra */
101104

102105
ob.dijkstra(graph, 0);
103106
}

0 commit comments

Comments
 (0)