From 983492115d96de2a04933f9ae01c4b6a1ed26c2c Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Fri, 17 Aug 2018 10:31:18 +0300 Subject: [PATCH] Fix tests. --- src/algorithms/graph/prim/__test__/prim.test.js | 2 +- src/data-structures/heap/Heap.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/algorithms/graph/prim/__test__/prim.test.js b/src/algorithms/graph/prim/__test__/prim.test.js index 797f5f5b..ac608df8 100644 --- a/src/algorithms/graph/prim/__test__/prim.test.js +++ b/src/algorithms/graph/prim/__test__/prim.test.js @@ -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', () => { diff --git a/src/data-structures/heap/Heap.js b/src/data-structures/heap/Heap.js index b5477716..59ed5f0f 100644 --- a/src/data-structures/heap/Heap.js +++ b/src/data-structures/heap/Heap.js @@ -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; }