New Matrix

This commit is contained in:
FUH22860 2022-06-17 13:00:20 +02:00
parent a42afb9642
commit b3a9cad35d

View File

@ -7,9 +7,15 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
public class Graph { public class Graph {
private static int[][] adjacent = { {0,1,0}, // private static int[][] adjacent = { {0,1,0},
{1,0,1}, // {1,0,1},
{0,1,0} }; // {0,1,0} };
private static int[][] adjacent = { {0,1,1,1,0},
{1,0,0,1,1},
{1,0,0,1,0},
{1,1,1,0,0},
{0,1,0,0,0} };
private static int[][] distance = { {0,1,2}, private static int[][] distance = { {0,1,2},
{1,0,1}, {1,0,1},
@ -41,7 +47,7 @@ public class Graph {
for(int pos = 0; pos < adjacent.length; pos++) { // Position in Array for(int pos = 0; pos < adjacent.length; pos++) { // Position in Array
adjacent2[row][col] += adjacent[row][pos] * adjacent[pos][col]; // row * col adjacent2[row][col] += adjacent[row][pos] * adjacent[pos][col]; // row * col
} }
} }
} }
return adjacent2; return adjacent2;
@ -57,6 +63,7 @@ public class Graph {
for (int j = 0; j < adjacent.length; j++) { for (int j = 0; j < adjacent.length; j++) {
System.out.print(adjacent2[i][j] + ", "); System.out.print(adjacent2[i][j] + ", ");
} }
System.out.println("\n");
} }
} }
else else