fix & improve reporting of cyclic dependencies

This commit is contained in:
Johannes
2025-06-09 15:02:25 +02:00
parent 950ac255ea
commit c5af7e2424
4 changed files with 32 additions and 35 deletions

View File

@@ -63,15 +63,15 @@ export namespace graph {
return this._nodes.get(data) ?? null;
}
findCycles(allData: T[]): Map<T, T[]> {
const result = new Map<T, T[]>();
findCycles(allData: T[]): Map<T, T[] | undefined> {
const result = new Map<T, T[] | undefined>();
const checked = new Set<T>();
for (const data of allData) {
const node = this.lookup(data);
if (!node) {
continue;
}
const r = this._findCycle(node, checked, new Set()) ?? [];
const r = this._findCycle(node, checked, new Set());
result.set(node.data, r);
}
return result;