Skip to content

Commit

Permalink
apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
winprn committed Jan 2, 2025
1 parent 2c0f722 commit 5adaf37
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions packages/object/src/hashgraph/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export class HashGraph {
return result;
}

kahnAlgorithm(origin: Hash, subgraph: ObjectSet<Hash>): Hash[] {
kahnsAlgorithm(origin: Hash, subgraph: ObjectSet<Hash>): Hash[] {
const result: Hash[] = [];
const inDegree = new Map<Hash, number>();
const queue: Hash[] = [];
Expand Down Expand Up @@ -284,13 +284,9 @@ export class HashGraph {

for (const child of this.forwardEdges.get(current) || []) {
if (!inDegree.has(child)) continue;
const inDegreeValue = inDegree.get(child);
if (inDegreeValue === undefined) {
log.error("::hashgraph::Kahn: Undefined in-degree value");
return [];
}
const inDegreeValue = inDegree.get(child) || 0;
inDegree.set(child, inDegreeValue - 1);
if (inDegree.get(child) === 0) {
if (inDegreeValue - 1 === 0) {
queue.push(child);
}
}
Expand All @@ -310,7 +306,7 @@ export class HashGraph {
origin: Hash = HashGraph.rootHash,
subgraph: ObjectSet<Hash> = new ObjectSet(this.vertices.keys()),
): Hash[] {
const result = this.kahnAlgorithm(origin, subgraph);
const result = this.kahnsAlgorithm(origin, subgraph);
if (!updateBitsets) return result;
this.reachablePredecessors.clear();
this.topoSortedIndex.clear();
Expand Down

0 comments on commit 5adaf37

Please sign in to comment.