Skip to content

Commit

Permalink
Removed error when availableNodes is null
Browse files Browse the repository at this point in the history
  • Loading branch information
richardclegg committed Jul 19, 2023
1 parent f775927 commit 478e446
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions feta/operations/Star.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public void updateLikelihoods(MixedModel obm, Network net) {
} else {
availableNodes = net.getNodeListCopy();
}

if (availableNodes.isEmpty()) {
System.err.println("No available target nodes to choose from! Operation "+this);
System.exit(-1);
Expand Down Expand Up @@ -158,11 +159,10 @@ public void pickCentreNode(Network net, MixedModel obm) {
HashSet<Integer> availableNodes;
if (centreType_ != null) {
availableNodes = nt.getNodesOfType(centreType_);
//System.out.println("Getting nodes of type "+centreType_+ " found "+availableNodes);
} else {
availableNodes = net.getNodeListCopy();
}

centreNode_ = obm.nodeDrawWithoutReplacement(net, availableNodes, -1);
centreNodeName_=net.nodeNoToName(centreNode_);
}
Expand All @@ -177,23 +177,23 @@ public void pickLeafNodes(Network net, MixedModel obm) throws Exception {
HashSet<Integer> availableNodes;
leafNodes_ = new int[noLeaves_];

net.getNodeListCopy().remove(centreNode_);
// Check which nodes are in the sample space for the existing nodes
if (leafType_ != null) {
availableNodes = nt.getNodesOfType(leafType_);
} else {
availableNodes = net.getNodeListCopy();
}
availableNodes.remove(centreNode_);


// Internal or external star.
int[] internalLeaves;
if (internal_) {
if (internal_ && availableNodes != null) {
for (int node: net.getOutLinks(centreNode_)) {
availableNodes.remove(node);
}
}

if (noExisting_ > availableNodes.size()) {
if (availableNodes != null && noExisting_ > availableNodes.size()) {
// cancel addition of the node to data structures
if (!internal_) {
net.rollBackNodeAddition();
Expand Down

0 comments on commit 478e446

Please sign in to comment.