allConditions static method

List<BayesCondition> allConditions(
  1. List<BayesVariable> nodes
)

Implementation

static List<BayesCondition> allConditions(List<BayesVariable> nodes) {
  var nodesLength = nodes.length;

  var minCombinations = math.min(nodesLength, 2);

  var combinations =
      nodes.combinations<BayesEvent>(minCombinations, nodesLength,
          allowRepetition: false,
          validator: nodesLength == 1
              ? (c) => true
              : (c) {
                  var idx = nodes.indexOf(c.first.node);
                  return idx == 0;
                },
          mapper: (node) => node.values.map((v) => BayesEvent(node, v)));

  var conditions =
      combinations.map((events) => BayesCondition(events)).toList();
  return conditions;
}