fauton
Version:
A library to test any finite automaton with arbitrary alphabets
23 lines (22 loc) • 886 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkEquivalenceBetweenStatesGroups = void 0;
function checkEquivalenceBetweenStatesGroups(statesGroups) {
const [statesGroupsOne, statesGroupsTwo] = statesGroups;
if (statesGroupsOne.length !== statesGroupsTwo.length)
return false;
let isEquivalent = true;
const stateGroupsSet = new Set();
statesGroupsOne.forEach((statesGroup) => {
stateGroupsSet.add(statesGroup.join(''));
});
for (let index = 0; index < statesGroupsTwo.length; index += 1) {
const statesGroup = statesGroupsTwo[index];
if (!stateGroupsSet.has(statesGroup.join(''))) {
isEquivalent = false;
break;
}
}
return isEquivalent;
}
exports.checkEquivalenceBetweenStatesGroups = checkEquivalenceBetweenStatesGroups;