This commit is contained in:
René Fuhry 2023-05-26 00:28:55 +02:00 committed by GitHub
parent 41680b3893
commit f9f636c6f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 12 deletions

View File

@ -17,11 +17,6 @@ public class Graph {
public static void main(String[] args) {}
public Graph(int rowLength, int columnLength) {
}
public Graph(String file) {
adjazenzMatrix = new Matrix(file);
calculateDistanzMatrix();
@ -34,7 +29,7 @@ public class Graph {
}
public void calculateDistanzMatrix() {
distanzMatrix = new Matrix(adjazenzMatrix.getRowLength(), adjazenzMatrix.getColumnLength(), false);
distanzMatrix = new Matrix(adjazenzMatrix.getRowLength(), adjazenzMatrix.getColumnLength());
Matrix potenzMatrix = adjazenzMatrix;
for(int columnIndex=0; columnIndex < distanzMatrix.getColumnLength(); columnIndex++) {
@ -63,7 +58,7 @@ public class Graph {
}
public void calculateWegMatrix() {
wegMatrix = new Matrix(adjazenzMatrix.getRowLength(), adjazenzMatrix.getColumnLength(), false);
wegMatrix = new Matrix(adjazenzMatrix.getRowLength(), adjazenzMatrix.getColumnLength());
Matrix potenzMatrix = adjazenzMatrix;
for(int columnIndex=0; columnIndex < wegMatrix.getColumnLength(); columnIndex++) {

View File

@ -15,13 +15,10 @@ public class Matrix {
readCSV(file);
}
public Matrix(int rowLength, int columnLength, boolean random) {
public Matrix(int rowLength, int columnLength) {
matrix = new int[rowLength][columnLength];
this.rowLength = rowLength;
this.columnLength = columnLength;
if(random) {
randomAdjazenzMatrix();
}
}
public Matrix(int[][] matrix) {
@ -83,6 +80,18 @@ public class Matrix {
}
}
public int[][] clone() {
int[][] clone = new int[rowLength][columnLength];
for(int columnIndex=0; columnIndex < columnLength; columnIndex++) {
for(int rowIndex=0; rowIndex < rowLength; rowIndex++) {
clone[rowIndex][columnIndex] = matrix[rowIndex][columnIndex];
}
}
return clone;
}
public void randomAdjazenzMatrix() {
Random r = new Random();
for(int columnIndex=0; columnIndex < columnLength; columnIndex++) {

View File

@ -13,7 +13,7 @@ public class TestMatrix {
scalarProduct = matrix.multiply(matrix);
System.out.println("\nScalarProduct A²: \n" + scalarProduct);
Matrix bruh = new Matrix(100, 100, true);
Matrix bruh = new Matrix(100, 100);
System.out.println(bruh);
}
}