From f9f636c6f3de4765cacb0df07e130e60f118ba7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Fuhry?= Date: Fri, 26 May 2023 00:28:55 +0200 Subject: [PATCH] revert --- src/Graph.java | 9 ++------- src/Matrix.java | 17 +++++++++++++---- src/TestMatrix.java | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Graph.java b/src/Graph.java index 83117f9..fef94a6 100644 --- a/src/Graph.java +++ b/src/Graph.java @@ -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++) { diff --git a/src/Matrix.java b/src/Matrix.java index 5216579..9104cf8 100644 --- a/src/Matrix.java +++ b/src/Matrix.java @@ -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++) { diff --git a/src/TestMatrix.java b/src/TestMatrix.java index fef242a..7e8b04a 100644 --- a/src/TestMatrix.java +++ b/src/TestMatrix.java @@ -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); } }