Skip to content

Commit ca9351c

Browse files
😒 chore: Remove debug code.
1 parent 17a9186 commit ca9351c

10 files changed

+0
-66
lines changed

src/FibonacciHeap.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Node from './Node';
22

3-
import list_debug from './list_debug';
43
import list_insert from './list_insert';
54
import list_remove from './list_remove';
65
import list_concatenate from './list_concatenate';
@@ -24,7 +23,6 @@ export default class FibonacciHeap {
2423
* cost of MAKE-FIB-HEAP is thus equal to its O(1) actual cost.
2524
*/
2625
constructor(compare) {
27-
//console.debug('constructor');
2826
this.compare = compare; // Comparison function
2927
/**
3028
* We access a given Fibonacci heap H by a pointer H.min to the root of
@@ -40,7 +38,6 @@ export default class FibonacciHeap {
4038
* Find-min: simply return the top element of the heap.
4139
*/
4240
head() {
43-
//console.debug('head');
4441
if (this.min === null) return undefined;
4542
return this.min.value;
4643
}
@@ -54,14 +51,12 @@ export default class FibonacciHeap {
5451
* its O(1) actual cost.
5552
*/
5653
headreference() {
57-
//console.debug('headreference');
5854
return this.min;
5955
}
6056

6157
/**
6258
*/
6359
pop() {
64-
//console.debug('pop');
6560
const min = this.popreference();
6661
return min === null ? undefined : min.value;
6762
}
@@ -81,22 +76,16 @@ export default class FibonacciHeap {
8176
* which we shall see shortly.
8277
*/
8378
popreference() {
84-
//console.debug('popreference');
8579
const z = this.min;
8680
if (z === null) return null;
87-
//console.debug('z is', z.value);
88-
list_debug(z.next, 'z list');
8981
if (z.children !== null) {
90-
list_debug(z.children, 'z children');
9182
list_reset_parent(z.children);
9283
list_concatenate(z, z.children);
93-
list_debug(z.next, 'z after concatenation with its children');
9484
}
9585

9686
if (z === z.next) this.min = null;
9787
else {
9888
list_remove(z);
99-
list_debug(z.next, 'z after removal');
10089
this.min = consolidate(this.compare, z.next);
10190
}
10291

@@ -105,15 +94,13 @@ export default class FibonacciHeap {
10594
z.children = null;
10695
z.degree = 0;
10796
z.mark = false;
108-
//console.debug('popped', z.value);
10997
return z;
11098
}
11199

112100
/**
113101
* Create a new node for the inserted element and put it into the heap.
114102
*/
115103
push(value) {
116-
//console.debug('push', value);
117104
const node = new Node(value);
118105
return this.pushreference(node);
119106
}
@@ -128,7 +115,6 @@ export default class FibonacciHeap {
128115
* Change in potential is 1. Therefore amortized cost is O(1).
129116
*/
130117
pushreference(ref) {
131-
//console.debug('pushreference');
132118
if (this.min === null) {
133119
// Create a root list for H containing just x (by precondition)
134120
this.min = ref;
@@ -158,7 +144,6 @@ export default class FibonacciHeap {
158144
* Change in potential is zero. Amortized cost is O(1), the actual cost.
159145
*/
160146
meld(other) {
161-
//console.debug('meld');
162147
const ref = other.min;
163148
if (ref === null) return;
164149
if (this.min === null) this.min = ref;
@@ -186,7 +171,6 @@ export default class FibonacciHeap {
186171
* @param {Object} value The new value for ref.
187172
*/
188173
update(ref, value) {
189-
//console.debug('update');
190174
const d = this.compare(value, ref.value);
191175

192176
if (d < 0) this.decreasekey(ref, value);
@@ -200,7 +184,6 @@ export default class FibonacciHeap {
200184
* @param {Object} value The new value for ref.
201185
*/
202186
decreasekey(ref, value) {
203-
//console.debug('decreasekey');
204187
ref.value = value;
205188
if (ref !== this.min) {
206189
// This.min != null, ref != null
@@ -226,7 +209,6 @@ export default class FibonacciHeap {
226209
*
227210
*/
228211
increasekey(ref, value) {
229-
//console.debug('increasekey');
230212
this.delete(ref);
231213

232214
ref.value = value;
@@ -240,8 +222,6 @@ export default class FibonacciHeap {
240222
* ref.prev and ref.next get reset to null
241223
*/
242224
delete(ref) {
243-
//console.debug('>>>>')
244-
//console.debug('DELETE', ref.value);
245225
if (ref !== this.min) {
246226
// This.min != null, ref != null
247227
const y = ref.parent;

src/cascading_cut.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import cut from './cut';
22

33
export default function* cascading_cut(y) {
4-
//console.debug('cascading_cut');
54
while (true) {
65
const z = y.parent;
76
if (z === null) break;

src/consolidate.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
import list_insert from './list_insert';
2-
import list_debug from './list_debug';
32
import fib_heap_link from './fib_heap_link';
43

5-
function debug_array ( A ) {
6-
7-
console.debug('DEGREE TABLE');
8-
for (let i = 0; i < A.length; ++i) {
9-
const x = A[i];
10-
if (x === null) continue;
11-
if (x.degree !== i) console.error('WRONG DEGREE');
12-
list_debug(x.children, i, x.value, '>');
13-
}
14-
15-
}
16-
174
/**
185
* CONSOLIDATE: Consolidate the root list of a heap.
196
*
@@ -40,13 +27,11 @@ function debug_array ( A ) {
4027
* @param l Root list.
4128
*/
4229
export default function consolidate(compare, l) {
43-
//console.debug('consolidate');
4430
const A = [];
4531

4632
let next = l;
4733

4834
do {
49-
//debug_array(A);
5035
let x = next;
5136
next = x.next;
5237
let d = x.degree;
@@ -80,8 +65,6 @@ export default function consolidate(compare, l) {
8065

8166
let min = null;
8267

83-
//debug_array(A);
84-
8568
for (const x of A) {
8669
if (x === null) continue;
8770
if (min === null) {
@@ -97,9 +80,5 @@ export default function consolidate(compare, l) {
9780
}
9881
}
9982

100-
//console.debug('ROOT LIST');
101-
//list_debug(min);
102-
//console.debug('=========');
103-
10483
return min;
10584
}

src/cut.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import list_remove from './list_remove';
22

33
export default function cut(x, y) {
4-
//console.debug('cut', x.value, 'from his parent', y.value);
54
if (x === x.next) y.children = null;
65
else {
76
y.children = x.next;

src/fib_heap_link.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,23 @@
11
import list_remove from './list_remove';
22
import list_insert from './list_insert';
3-
import list_debug from './list_debug';
43

54
/**
65
* FIB-HEAP-LINK
76
*
87
* Precondition: y is in the root list of some heap.
98
*/
109
export default function fib_heap_link(y, x) {
11-
//console.debug('fib_heap_link BEGIN', y.value, x.value);
12-
//list_debug(y.next, 'y siblings');
1310
//list_remove(y); // NOT NECESSARY SINCE y IS ALWAYS FROM ROOT LIST
14-
//list_debug(y.next, 'y siblings after');
1511
// make y a child of x
1612
if (x.children === null) {
17-
//console.debug('children of', x.value, 'before', []);
1813
y.next = y;
1914
y.prev = y;
2015
x.children = y;
2116
} else {
22-
//list_debug(x.children, 'children of', x.value, 'before');
2317
list_insert(x.children, y);
2418
}
2519

26-
//list_debug(x.children, 'children of', x.value, 'after');
27-
2820
y.parent = x;
2921
++x.degree; // Increment x.degree
3022
y.mark = false; // Unmark y
31-
//console.debug('fib_heap_link END');
3223
}

src/list_concatenate.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export default function list_concatenate(x, y) {
2-
//console.debug('list_concatenate');
32
// FROM x - b - c - d - x y - f - g - h - y
43
// TO x - b - c - d - y - f - g - h - x
54
const d = x.prev;

src/list_debug.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/list_iter.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export default function* list_iter(children) {
2-
//console.debug('list_iter');
32
let next = children;
43

54
do {

src/list_remove.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* /!\ y will have dangling pointers after removal if not single element
44
*/
55
export default function list_remove(y) {
6-
//console.debug('list_remove');
76
y.prev.next = y.next;
87
y.next.prev = y.prev;
98
}

src/list_reset_parent.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export default function list_reset_parent(children) {
2-
//console.debug('list_reset_parent');
32
let next = children;
43

54
do {
@@ -8,5 +7,4 @@ export default function list_reset_parent(children) {
87
x.parent = null;
98
} while (next !== children);
109

11-
//console.debug('DONE');
1210
}

0 commit comments

Comments
 (0)