small fix (#5)

This commit is contained in:
René Fuhry 2023-05-25 23:29:26 +02:00 committed by GitHub
commit e95b94ec7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,11 +95,19 @@ public class Graph {
exzentrizität = distanzMatrix.getValueAt(columnIndex, rowIndex); exzentrizität = distanzMatrix.getValueAt(columnIndex, rowIndex);
} }
} }
if(exzentrizität == 0) {
connected = false;
return;
}
exzentrizitäten.add(exzentrizität); exzentrizitäten.add(exzentrizität);
} }
} }
public void calculateProperties() { public void calculateProperties() {
if(!connected) {
return;
}
radius = Integer.MAX_VALUE; radius = Integer.MAX_VALUE;
diameter = -1; diameter = -1;
connected = true; connected = true;
@ -108,20 +116,16 @@ public class Graph {
for(int rowIndex = 0; rowIndex < exzentrizitäten.size(); rowIndex++) { for(int rowIndex = 0; rowIndex < exzentrizitäten.size(); rowIndex++) {
if(exzentrizitäten.get(rowIndex) > diameter) { if(exzentrizitäten.get(rowIndex) > diameter) {
diameter = exzentrizitäten.get(rowIndex); diameter = exzentrizitäten.get(rowIndex);
centre.clear(); }
if(exzentrizitäten.get(rowIndex) == radius) {
centre.add(rowIndex + 1); centre.add(rowIndex + 1);
} }
if(exzentrizitäten.get(rowIndex) < radius) { if(exzentrizitäten.get(rowIndex) < radius) {
radius = exzentrizitäten.get(rowIndex); radius = exzentrizitäten.get(rowIndex);
} centre.clear();
if(exzentrizitäten.get(rowIndex) == diameter) {
centre.add(rowIndex + 1); centre.add(rowIndex + 1);
} }
} }
if(radius == 0) {
connected = false;
}
} }
public void findComponents() { public void findComponents() {