privateintnumberofvertices;//number of vertices in the graph
publicstaticfinalintINFINITY = 999;
publicFloydWarshall(intnumberofvertices) {
DistanceMatrix = newint[numberofvertices + 1][numberofvertices + 1];//stores the value of distance from all the possible path form the source vertex to destination vertex
Arrays.fill(DistanceMatrix, 0);
this.numberofvertices = numberofvertices;
}
publicvoidfloydwarshall(intAdjacencyMatrix[][])//calculates all the distances from source to destination vertex
{
for (intsource = 1; source <= numberofvertices; source++) {
for (intdestination = 1; destination <= numberofvertices; destination++) {