mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-12-25 22:46:20 +08:00
Fix tests.
This commit is contained in:
parent
980601295d
commit
983492115d
@ -55,7 +55,7 @@ describe('prim', () => {
|
||||
expect(minimumSpanningTree.getWeight()).toBe(24);
|
||||
expect(minimumSpanningTree.getAllVertices().length).toBe(graph.getAllVertices().length);
|
||||
expect(minimumSpanningTree.getAllEdges().length).toBe(graph.getAllVertices().length - 1);
|
||||
expect(minimumSpanningTree.toString()).toBe('A,B,D,C,E,F,G');
|
||||
expect(minimumSpanningTree.toString()).toBe('A,B,C,E,D,F,G');
|
||||
});
|
||||
|
||||
it('should find minimum spanning tree for simple graph', () => {
|
||||
|
@ -257,9 +257,9 @@ export default class Heap {
|
||||
nextIndex = this.getLeftChildIndex(currentIndex);
|
||||
}
|
||||
|
||||
if (!this.pairIsInCorrectOrder(
|
||||
this.heapContainer[nextIndex],
|
||||
if (this.pairIsInCorrectOrder(
|
||||
this.heapContainer[currentIndex],
|
||||
this.heapContainer[nextIndex],
|
||||
)) {
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user