minimum requirements fullfilled #4
@ -1,5 +1,4 @@
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class Graph {
|
public class Graph {
|
||||||
private Matrix adjazenzMatrix;
|
private Matrix adjazenzMatrix;
|
||||||
@ -8,7 +7,7 @@ public class Graph {
|
|||||||
private int[] exzentrizitäten;
|
private int[] exzentrizitäten;
|
||||||
private int radius;
|
private int radius;
|
||||||
private int durchmesser;
|
private int durchmesser;
|
||||||
private ArrayList<Integer> zentrum;
|
private int[] zentrum;
|
||||||
|
|
||||||
public static void main(String[] args) {}
|
public static void main(String[] args) {}
|
||||||
|
|
||||||
@ -91,29 +90,37 @@ public class Graph {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void calculateProperties() {
|
public void calculateProperties() {
|
||||||
Arrays.sort(exzentrizitäten);
|
radius = Integer.MAX_VALUE;
|
||||||
radius = exzentrizitäten[0];
|
durchmesser = 0;
|
||||||
durchmesser = exzentrizitäten[exzentrizitäten.length - 1];
|
int sum = 1;
|
||||||
zentrum = new ArrayList<>();
|
|
||||||
|
|
||||||
for(int eRowIndex=exzentrizitäten.length - 1, index = 0; eRowIndex > 0 && index < exzentrizitäten.length; eRowIndex--, index++) {
|
for(int rowIndex = 0; rowIndex < exzentrizitäten.length; rowIndex++) {
|
||||||
if(exzentrizitäten[eRowIndex] == durchmesser) {
|
if(exzentrizitäten[rowIndex] < radius) {
|
||||||
zentrum.add(index, durchmesser);
|
radius = exzentrizitäten[rowIndex];
|
||||||
|
}
|
||||||
|
if(exzentrizitäten[rowIndex] == durchmesser) {
|
||||||
|
sum++;
|
||||||
|
}
|
||||||
|
if(exzentrizitäten[rowIndex] > durchmesser) {
|
||||||
|
durchmesser = exzentrizitäten[rowIndex];
|
||||||
|
sum = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zentrum = new int[sum];
|
||||||
|
|
||||||
|
for(int rowIndex = 0, index = 0; rowIndex < exzentrizitäten.length; rowIndex++) {
|
||||||
|
if(exzentrizitäten[rowIndex] == durchmesser) {
|
||||||
|
zentrum[index] = rowIndex + 1;
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
zentrum.toArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String s = "";
|
String s = "";
|
||||||
|
|
||||||
s += "Adjazenzmatrix: \n" + adjazenzMatrix + "\nDistanzmatrix: \n" + distanzMatrix + "\nWegmatrix: \n" + wegMatrix + "\nExzentrizitäten: \n";
|
s += "Adjazenzmatrix:\n" + adjazenzMatrix + "\nDistanzmatrix:\n" + distanzMatrix + "\nWegmatrix:\n" + wegMatrix;
|
||||||
|
s += "\nExzentrizitäten: " + Arrays.toString(exzentrizitäten) + "\nRadius: " + radius + "\nDurchmesser: " + durchmesser + "\nZentrum: " + Arrays.toString(zentrum);
|
||||||
for(int rowIndex=0; rowIndex < exzentrizitäten.length; rowIndex++) {
|
|
||||||
s += exzentrizitäten[rowIndex] + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
s += "\nRadius: " + radius + "\nDurchmesser: " + durchmesser + "\nZentrum: " + zentrum;
|
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
public class TestGraph {
|
public class TestGraph {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
test1("/home/old/projects/Java/graphprogram/24n_01.csv");
|
Graph g = new Graph("/home/old/projects/Java/graphprogram/graph.csv");
|
||||||
}
|
|
||||||
|
|
||||||
public static void test1(String file) {
|
|
||||||
Graph g = new Graph(file);
|
|
||||||
g.calculateExzentrizitäten();
|
g.calculateExzentrizitäten();
|
||||||
g.calculateProperties();
|
g.calculateProperties();
|
||||||
System.out.println(g);
|
System.out.println(g);
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
public class TestMatrix {
|
public class TestMatrix {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
test1("/home/old/projects/Java/graphprogram/24n_01.csv");
|
Matrix matrix = new Matrix("/home/old/projects/Java/graphprogram/24n_01.csv");
|
||||||
}
|
|
||||||
|
|
||||||
public static void test1(String file) {
|
|
||||||
Matrix matrix = new Matrix(file);
|
|
||||||
Matrix scalarProduct;
|
Matrix scalarProduct;
|
||||||
|
|
||||||
System.out.println(matrix.getRowLength());
|
System.out.println(matrix.getRowLength());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user