evaluate method

  1. @override
List<Fact> evaluate(
  1. Map<String, List<List<Object>>> facts,
  2. Map<String, List<List<Object>>> derived
)
override

Evaluates the rule and returns derived facts.

Implementation

@override
List<Fact> evaluate(
  Map<String, List<List<Object>>> facts,
  Map<String, List<List<Object>>> derived,
) {
  final result = <Fact>[];
  final flows = facts['Flow'] ?? [];
  final reachable = getCombined('Reachable', facts, derived);

  for (final flow in flows) {
    final from = flow[0];
    final to = flow[1];

    for (final r in reachable) {
      if (r[0] == from) {
        result.add(Fact('Reachable', [to]));
      }
    }
  }

  return result;
}