new method
This commit is contained in:
parent
2448464ed4
commit
2de0ac5a02
@ -1,5 +1,6 @@
|
|||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Random;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
|
||||||
@ -18,6 +19,7 @@ public class Matrix {
|
|||||||
matrix = new int[rowLength][columnLength];
|
matrix = new int[rowLength][columnLength];
|
||||||
this.rowLength = rowLength;
|
this.rowLength = rowLength;
|
||||||
this.columnLength = columnLength;
|
this.columnLength = columnLength;
|
||||||
|
randomAdjazenzMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Matrix(int[][] matrix) {
|
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() {
|
public String toString() {
|
||||||
String s = "";
|
String s = "";
|
||||||
for(int columnIndex=0; columnIndex < columnLength; columnIndex++) {
|
for(int columnIndex=0; columnIndex < columnLength; columnIndex++) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
public class TestMatrix {
|
public class TestMatrix {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String pathToProgramRoot = "";
|
String pathToProgramRoot = "/home/rene/projects/Java/graphprogram";
|
||||||
|
|
||||||
Matrix matrix = new Matrix(pathToProgramRoot + "/csv/graph.csv");
|
Matrix matrix = new Matrix(pathToProgramRoot + "/csv/graph.csv");
|
||||||
Matrix scalarProduct;
|
Matrix scalarProduct;
|
||||||
@ -12,5 +12,8 @@ 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);
|
||||||
|
System.out.println(bruh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user