diff --git a/src/Matrix.java b/src/Matrix.java index c62b760..86fd612 100644 --- a/src/Matrix.java +++ b/src/Matrix.java @@ -1,5 +1,6 @@ import java.io.BufferedReader; import java.io.IOException; +import java.util.Random; import java.io.FileReader; import java.io.FileNotFoundException; @@ -18,6 +19,7 @@ public class Matrix { matrix = new int[rowLength][columnLength]; this.rowLength = rowLength; this.columnLength = columnLength; + randomAdjazenzMatrix(); } public Matrix(int[][] matrix) { @@ -79,6 +81,18 @@ public class Matrix { } } + public void randomAdjazenzMatrix() { + Random r = new Random(); + for(int columnIndex=0; columnIndex < columnLength; columnIndex++) { + for(int rowIndex=0; rowIndex < rowLength; rowIndex++) { + if(rowIndex == columnIndex) { + continue; + } + matrix[rowIndex][columnIndex] = r.nextInt(2); + } + } + } + public String toString() { String s = ""; for(int columnIndex=0; columnIndex < columnLength; columnIndex++) { diff --git a/src/TestMatrix.java b/src/TestMatrix.java index 54c2ad3..7e8b04a 100644 --- a/src/TestMatrix.java +++ b/src/TestMatrix.java @@ -1,6 +1,6 @@ public class TestMatrix { public static void main(String[] args) { - String pathToProgramRoot = ""; + String pathToProgramRoot = "/home/rene/projects/Java/graphprogram"; Matrix matrix = new Matrix(pathToProgramRoot + "/csv/graph.csv"); Matrix scalarProduct; @@ -12,5 +12,8 @@ public class TestMatrix { scalarProduct = matrix.multiply(matrix); System.out.println("\nScalarProduct A²: \n" + scalarProduct); + + Matrix bruh = new Matrix(100, 100); + System.out.println(bruh); } }