quick fix

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

View File

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

View File

@ -15,11 +15,13 @@ public class Matrix {
readCSV(file); readCSV(file);
} }
public Matrix(int rowLength, int columnLength) { public Matrix(int rowLength, int columnLength, boolean random) {
matrix = new int[rowLength][columnLength]; matrix = new int[rowLength][columnLength];
this.rowLength = rowLength; this.rowLength = rowLength;
this.columnLength = columnLength; this.columnLength = columnLength;
randomAdjazenzMatrix(); if(random) {
randomAdjazenzMatrix();
}
} }
public Matrix(int[][] matrix) { public Matrix(int[][] matrix) {

View File

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