This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const PriorityQueue = (() => { | |
| const parent = i => ((i + 1) >>> 1) - 1 | |
| const left = i => (i << 1) + 1 | |
| const right = i => (i + 1) << 1 | |
| const privateMap = new WeakMap() | |
| const $ = privateMap.get.bind(privateMap) | |
| const swap = (self, i, j) => { | |
| const h = $(self).heap |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const parseGraph = s => s | |
| .split(',') | |
| .map(edge => edge.trim().split('->')) | |
| .reduce((adjacency, [a, b]) => { | |
| if (!adjacency.has(a)) { | |
| adjacency.set(a, new Set()) | |
| } | |
| if (!adjacency.has(b)) { | |
| adjacency.set(b, new Set()) | |
| } |
OlderNewer