To know all values of all nodes of the Bayesian network

@param bn
@return hashmap in format [node, [status, hypothesis]]
@throws UnknownNodeException
503558
public static HashMap<String, HashMap<String, Float>> getAllHypotheses(
            ProbabilisticNetwork bn) throws ShanksException {
        List<Node> nodes = bn.getNodes();
        HashMap<String, HashMap<String, Float>> result = new HashMap<String, HashMap<String, Float>>();
        for (Node node : nodes) {
            String nodeName = node.getName();
            HashMap<String, Float> hypotheses = ShanksAgentBayesianReasoningCapability
                    .getNodeStatesHypotheses(bn, nodeName);
            result.put(nodeName, hypotheses);
        }
        return result;
    }
943621
NodeAVL getNextNode(NodeAVL n) {

        if (n == null) {
            n = nPrimaryNode;
        } else {
            n = n.nNext;
        }

        return n;
    }
741051
public ArrayList<Pair<String, Integer>> nodes() {
        string_int_pair_vector v = ti.nodes();
        int size = (int) v.size();

        ArrayList<Pair<String, Integer>> l = new ArrayList<>(size);

        for (int i = 0; i < size; i++) {
            string_int_pair p = v.get(i);
            l.add(new Pair<>(p.getFirst(), p.getSecond()));
        }

        return l;
    }
361931
private static ArrayList<SimpleEntry<String, String>> traverseNode(Node n, String p) {
        ArrayList<SimpleEntry<String, String>> output = new ArrayList<>();
        String nName;
        if (n.getNodeType() != Node.TEXT_NODE) {
            nName = n.getNodeName();
            if (nName.startsWith("m:")) {
                nName = nName.substring(2);
            }
            if (nName.equals("mws:qvar")) {
                return new ArrayList<>();
            }
            p += "/" + nName;
        }
        String nValue = n.getNodeValue();
        if (nValue != null) {
            nValue = nValue.trim();
            if (nValue.length() == 0) {
                return new ArrayList<>();
            }
        } else {
            nValue = "";
        }

        if (!n.hasChildNodes()) {
            output.add(new SimpleEntry<>(p, nValue));
        } else {
            for (int i = 0; i < n.getChildNodes().getLength(); i++) {
                output.addAll(traverseNode(n.getChildNodes().item(i), p));
            }
        }
        return output;
    }
912018
@SuppressWarnings("unchecked")
  <T extends GraphNode<N, E>> T getNodeOrFail(N val) {
    T node = (T) getNode(val);
    if (node == null) {
      throw new IllegalArgumentException(val + " does not exist in graph");
    }
    return node;
  }
146206
public JSONObject nodesMapToJSON(StaticRouting.NodesMap nm) {
        JSONObject o = new JSONObject();
        o.put("src", nm.getSrc().id());
        o.put("dst", nm.getDst().id());
        return o;
    }
295037
public Map<String, MBeanAttributeInfo> getAttributeMetadata() {

        MBeanAttributeInfo[] attributeList = mBeanInfo.getAttributes();

        Map<String, MBeanAttributeInfo> attributeMap = new TreeMap<String, MBeanAttributeInfo>();
        for (MBeanAttributeInfo attribute: attributeList) {
            attributeMap.put(attribute.getName(), attribute);
        }
        return attributeMap;
    }
611590
public static void addEvidences(Network bn, Map<String, String> evidences)
            throws ShanksException {
        if (bn == null || evidences.isEmpty()) {
            throw new ShanksException("Null parameter in addEvidences method.");
        }
        for (Entry<String, String> evidence : evidences.entrySet()) {
            ShanksAgentBayesianReasoningCapability.addEvidence(bn,
                    evidence.getKey(), evidence.getValue());
        }
    }
424804
public SortedMap<String, byte[]> annotations()
	{
		SortedMap<String,byte[]> ann = new TreeMap<String, byte[]>();
		if(correlation_id!=null) {
			long hi = correlation_id.getMostSignificantBits();
			long lo = correlation_id.getLeastSignificantBits();
			ann.put("CORR", ByteBuffer.allocate(16).putLong(hi).putLong(lo).array());
		}
		return ann;
	}
607482
public static QName fromNode(final Node nd) {
    String ns = nd.getNamespaceURI();

    if (ns == null) {
      /* It appears a node can have a NULL namespace but a QName has a zero length
       */
      ns = "";
    }

    return new QName(ns, nd.getLocalName());
  }
764862
public static void addEvidence(ProbabilisticNetwork bn, String nodeName,
            String status) throws ShanksException {
        ProbabilisticNode node = ShanksAgentBayesianReasoningCapability
                .getNode(bn, nodeName);
        if (node.hasEvidence()) {
            ShanksAgentBayesianReasoningCapability.clearEvidence(bn, node);
        }
        int states = node.getStatesSize();
        for (int i = 0; i < states; i++) {
            if (status.equals(node.getStateAt(i))) {
                node.addFinding(i);
                try {
                    bn.updateEvidences();
                } catch (Exception e) {
                    throw new ShanksException(e);
                }
                return;
            }
        }
        throw new UnknowkNodeStateException(bn, nodeName, status);
    }
322043
public static void addSoftEvidence(Network bn, String nodeName,
            HashMap<String, Double> softEvidence) throws ShanksException {
        String auxNodeName = softEvidenceNodePrefix + nodeName;
        int targetNode = bn.getNode(nodeName);
        boolean found = false;
        int[] children = bn.getChildren(targetNode);
        for (int child : children) {
            if (bn.getNodeName(child).equals(auxNodeName)) {
                if (bn.getOutcomeCount(child) == 2
                        && bn.getOutcomeId(child, 0).equals(triggerState)) {
                    found = true;
                    break;
                }
            }
        }
        if (!found) {
            // Create soft-evidence node
            bn.addNode(NodeType.Cpt, auxNodeName);
            bn.setNodeName(auxNodeName, auxNodeName);
            int node = bn.getNode(auxNodeName);
            bn.setOutcomeId(node, 0, triggerState);
            bn.setOutcomeId(node, 1, "NON" + triggerState);
            // bn.insertOutcome(auxNode, 0, triggerState);
            // bn.insertOutcome(auxNode, 1, "NON" + triggerState);
            double[] cpt = bn.getNodeDefinition(auxNodeName);
            for (int i = 0; i < cpt.length; i++) {
                cpt[i] = (float) 0.5;
            }

            bn.addArc(targetNode, bn.getNode(auxNodeName));
            cpt = bn.getNodeDefinition(auxNodeName);
            for (int i = 0; i < cpt.length; i++) {
                cpt[i] = (float) 0.5;
            }
        }
        ShanksAgentBayesianReasoningCapability
                .updateSoftEvidenceAuxiliaryNodeCPT(bn, nodeName, softEvidence);
        ShanksAgentBayesianReasoningCapability.addEvidence(bn,
                softEvidenceNodePrefix + nodeName, triggerState);

    }
1068020
public static void addEvidence(Network bn, String nodeName, String status)
            throws ShanksException {

        if (bn == null || nodeName == null || status == null) {
            throw new ShanksException("Null parameter in addEvidence method.");
        }
        try {
            if (!bn.isPropagatedEvidence(nodeName)) {
                if (bn.isRealEvidence(nodeName)) {
                    bn.clearEvidence(nodeName);
                }
                bn.setEvidence(nodeName, status);
                bn.updateBeliefs();
            }
        } catch (Exception e) {
            bn.updateBeliefs();
            HashMap<String, Float> belief = ShanksAgentBayesianReasoningCapability
                    .getNodeStatesHypotheses(bn, nodeName);

            String msg = e.getMessage() + " -> values for node: " + nodeName
                    + " -> ";
            boolean zeroBel = false;
            for (Entry<String, Float> entry : belief.entrySet()) {
                if (status.equals(entry.getKey()) && entry.getValue() == 0.0f) {
                    zeroBel = true;
                    // Impossible value calculated by inference (this is because the BN is a big shit...
                    // But it is not a real error...
                    break;
                }
                msg = msg + entry.getKey() + "-" + entry.getValue() + " ";
            }
            if (!zeroBel) {
                throw new ShanksException(msg);
            }
        }
    }
1066978
public Map<String, T> getNodes() {
        return Maps.transformValues(Collections.unmodifiableMap(_nodes), input -> (input != null) ? input.orElse(null) : null);
    }
1210888
public static <BEAN, KEYTYPE> Set<KEYTYPE> getNoDataKeySet(Map<KEYTYPE, BEAN> map) {
		Set<KEYTYPE> keySet = null;
		Iterator<Entry<KEYTYPE, BEAN>> iterator = map.entrySet().iterator();
		while (iterator.hasNext()) {
			Entry<KEYTYPE, BEAN> entry = iterator.next();
			BEAN bean = entry.getValue();
			if (bean == null) {
				if (keySet == null) {
					keySet = new LinkedHashSet<KEYTYPE>();
				}
				keySet.add(entry.getKey());
			}
		}
		return keySet;
	}
186911
public static HashMap<String, Float> getNodeStatesHypotheses(Network bn,
            String nodeName) throws ShanksException {
        try {
            int node = ShanksAgentBayesianReasoningCapability.getNode(bn,
                    nodeName);
            String[] states = bn.getOutcomeIds(node);
            HashMap<String, Float> result = new HashMap<String, Float>();
            for (int i = 0; i < states.length; i++) {
                String status = states[i];
                Float hypothesis = (float) bn.getNodeValue(node)[i];
                result.put(status, hypothesis);
            }
            return result;
        } catch (Exception e) {
            throw new ShanksException("Problem getting hypotheses from: "
                    + nodeName + " -> Exception message: " + e.getMessage());
        }
    }
581858
def get_network(self):
        
        props = self.get_chain_properties()
        chain_id = props["chain_id"]
        for k, v in known_chains.items():
            if v["chain_id"] == chain_id:
                return v
        raise exceptions.UnknownNetworkException(
            "Connecting to unknown network (chain_id: {})!".format(props["chain_id"])
        )