Implementation
List<List<int>> get adjacencyMatrix {
final matrix = <List<int>>[];
for (var idxA = 0; idxA < _states.length; idxA++) {
final row = <int>[];
final stateA = _states.elementAt(idxA);
final transitions = switch (this) {
DeterministicAutomaton() => stateA.transitions.values,
NonDeterministicAutomaton() =>
stateA.transitions.values.expand((values) => values),
};
for (var idxB = 0; idxB < _states.length; idxB++) {
final stateB = _states.elementAt(idxB);
final quantity = transitions.where((state) => state == stateB).length;
row.add(quantity);
}
matrix.add(row);
}
return matrix;
}