1
0
mirror of https://github.com/robonen/eulerian-cycle.git synced 2026-03-20 10:54:46 +00:00

Fixed displaying steps in the player

This commit is contained in:
2021-12-16 15:14:59 +07:00
parent 098d020105
commit 24abf2c840
4 changed files with 108 additions and 73 deletions

View File

@@ -131,6 +131,16 @@ export default {
});
};
const checkGraph = () => {
euler.loadLinks(Object.values(links.value));
if (links.value.length > 0 && euler.check()) {
emit("hasEuler", euler.find());
} else {
emit("hasEuler", null);
}
};
// Nodes
const activateNodes = (ids) =>
ids.forEach((e) => (nodes.value[e].selected = true));
@@ -149,6 +159,7 @@ export default {
if (hasntIntersections(newNode)) {
nodes.value.push(newNode);
emit("hasVertices", nodes.value.length);
}
};
@@ -167,7 +178,8 @@ export default {
nodes.value = nodes.value.filter((_, idx) => idx !== id);
emit("isEuler", []);
checkGraph();
emit("hasVertices", nodes.value.length);
};
const selectNode = (id) => {
@@ -245,10 +257,7 @@ export default {
target,
});
euler.loadLinks(Object.values(links.value));
if (euler.check()) emit("isEuler", euler.find());
else emit("isEuler", []);
checkGraph();
});
const removeLink = (id) => {