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