fixed findProperties and a improvement
This commit is contained in:
parent
7f0849e1b1
commit
75c6a0579f
@ -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() {
|
||||||
|
Loading…
Reference in New Issue
Block a user