mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-12-26 23:21:18 +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.getWeight()).toBe(24);
|
||||||
expect(minimumSpanningTree.getAllVertices().length).toBe(graph.getAllVertices().length);
|
expect(minimumSpanningTree.getAllVertices().length).toBe(graph.getAllVertices().length);
|
||||||
expect(minimumSpanningTree.getAllEdges().length).toBe(graph.getAllVertices().length - 1);
|
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', () => {
|
it('should find minimum spanning tree for simple graph', () => {
|
||||||
|
@ -257,9 +257,9 @@ export default class Heap {
|
|||||||
nextIndex = this.getLeftChildIndex(currentIndex);
|
nextIndex = this.getLeftChildIndex(currentIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.pairIsInCorrectOrder(
|
if (this.pairIsInCorrectOrder(
|
||||||
this.heapContainer[nextIndex],
|
|
||||||
this.heapContainer[currentIndex],
|
this.heapContainer[currentIndex],
|
||||||
|
this.heapContainer[nextIndex],
|
||||||
)) {
|
)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user