Refactor connection weight calculation to use ArrayList for fixing bug
This commit is contained in:
@@ -170,14 +170,13 @@ public final class Net implements Iterable<ServerNode> {
|
|||||||
for (var conn : list)
|
for (var conn : list)
|
||||||
sum += conn.weight;
|
sum += conn.weight;
|
||||||
|
|
||||||
var newOne = new Connection[list.size()];
|
var newOne = new ArrayList<Connection>();
|
||||||
for (var i = 0; i < list.size(); i++) {
|
for (var conn : list) {
|
||||||
var conn = list.get(i);
|
|
||||||
var newWeight = conn.weight / sum;
|
var newWeight = conn.weight / sum;
|
||||||
newOne[i] = new Connection(conn.index, newWeight);
|
newOne.add(new Connection(conn.index, newWeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.connections.set(node, List.of(newOne));
|
this.connections.set(node, newOne);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user