Remove redundant exception for connecting to source nodes in addConnection method

This commit is contained in:
2025-02-14 15:47:19 +01:00
parent 64e135810a
commit 1cab669fd9

View File

@@ -75,7 +75,6 @@ public final class Net implements Iterable<ServerNode> {
* @param weight The probability of the child node.
* @throws IndexOutOfBoundsException if one of the two nodes are not in the net
* @throws IllegalArgumentException if the weight is negative or zero
* @throws IllegalArgumentException if the child is a source node
*/
public void addConnection(int parent, int child, double weight) {
if (weight <= 0)
@@ -85,9 +84,6 @@ public final class Net implements Iterable<ServerNode> {
if (parent < 0 || child < 0 || parent > max || child > max)
throw new IndexOutOfBoundsException("One of the nodes does not exist");
if (this.servers.get(child).spawnArrivals > 0)
throw new IllegalArgumentException("Can't connect to a source node");
var list = this.connections.get(parent);
list.removeIf(conn -> conn.index == child);
list.add(new Connection(child, weight));