When changing the NodeType of a node in a ProbNet, the method getNode(NodeType) does not return the correct nodes

Create issue
Issue #192 resolved
Miguel Ángel Artaso Landa created an issue

When in a ProbNet a node is changed its NodeType, e.g., if we change the NodeType to a node of type DECISION,

probNet.getNode(node.getName()).setNodeType(NodeType.CHANCE);

In the probNet variable, the node appears with its new type, but if the following code is executed

List<Node> decisionNodes = probNet.getNodes(NodeType.DECISION);

in the list shows up the node that previously was a DECISION and now is of CHANCE type.

It seems that the NodeTypeDepot class is not updating the nodesHashMaps variable accordingly.

Comments (2)

  1. Miguel Ángel Artaso Landa reporter

    In the Node class, the method setNodeType was changing the attribute nodeType, but the nodeDepot attribute of the ProbNet class was not being informed of the change. The method has been updated to do so:

    #!java
    
    public void setNodeType(NodeType nodeType) {
           // Remove node from NodeTypeDepot HashMap
            this.probNet.nodeDepot.removeNode(this);
            // Change of nodeType
            this.nodeType = nodeType;
            // Add node to NodeTypeDepot HashMap
            this.probNet.nodeDepot.addNode(this);
    }
    
  2. Log in to comment