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; }