-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
2,032 additions
and
0 deletions.
There are no files selected for viewing
100 changes: 100 additions & 0 deletions
100
...-/dijkstrajs@v1.0.3-OWjFuN52EraKtSJbLxCP/dist=es2019,mode=imports/optimized/dijkstrajs.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
function createCommonjsModule(fn, basedir, module) { | ||
return module = { | ||
path: basedir, | ||
exports: {}, | ||
require: function(path, base) { | ||
return commonjsRequire(path, base === void 0 || base === null ? module.path : base); | ||
} | ||
}, fn(module, module.exports), module.exports; | ||
} | ||
function commonjsRequire() { | ||
throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs"); | ||
} | ||
var dijkstra_1 = createCommonjsModule(function(module) { | ||
var dijkstra = { | ||
single_source_shortest_paths: function(graph, s, d) { | ||
var predecessors = {}; | ||
var costs = {}; | ||
costs[s] = 0; | ||
var open = dijkstra.PriorityQueue.make(); | ||
open.push(s, 0); | ||
var closest, u, v, cost_of_s_to_u, adjacent_nodes, cost_of_e, cost_of_s_to_u_plus_cost_of_e, cost_of_s_to_v, first_visit; | ||
while (!open.empty()) { | ||
closest = open.pop(); | ||
u = closest.value; | ||
cost_of_s_to_u = closest.cost; | ||
adjacent_nodes = graph[u] || {}; | ||
for (v in adjacent_nodes) { | ||
if (adjacent_nodes.hasOwnProperty(v)) { | ||
cost_of_e = adjacent_nodes[v]; | ||
cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e; | ||
cost_of_s_to_v = costs[v]; | ||
first_visit = typeof costs[v] === "undefined"; | ||
if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) { | ||
costs[v] = cost_of_s_to_u_plus_cost_of_e; | ||
open.push(v, cost_of_s_to_u_plus_cost_of_e); | ||
predecessors[v] = u; | ||
} | ||
} | ||
} | ||
} | ||
if (typeof d !== "undefined" && typeof costs[d] === "undefined") { | ||
var msg = ["Could not find a path from ", s, " to ", d, "."].join(""); | ||
throw new Error(msg); | ||
} | ||
return predecessors; | ||
}, | ||
extract_shortest_path_from_predecessor_list: function(predecessors, d) { | ||
var nodes = []; | ||
var u = d; | ||
while (u) { | ||
nodes.push(u); | ||
predecessors[u]; | ||
u = predecessors[u]; | ||
} | ||
nodes.reverse(); | ||
return nodes; | ||
}, | ||
find_path: function(graph, s, d) { | ||
var predecessors = dijkstra.single_source_shortest_paths(graph, s, d); | ||
return dijkstra.extract_shortest_path_from_predecessor_list(predecessors, d); | ||
}, | ||
PriorityQueue: { | ||
make: function(opts) { | ||
var T = dijkstra.PriorityQueue, t = {}, key; | ||
opts = opts || {}; | ||
for (key in T) { | ||
if (T.hasOwnProperty(key)) { | ||
t[key] = T[key]; | ||
} | ||
} | ||
t.queue = []; | ||
t.sorter = opts.sorter || T.default_sorter; | ||
return t; | ||
}, | ||
default_sorter: function(a, b) { | ||
return a.cost - b.cost; | ||
}, | ||
push: function(value, cost) { | ||
var item = {value, cost}; | ||
this.queue.push(item); | ||
this.queue.sort(this.sorter); | ||
}, | ||
pop: function() { | ||
return this.queue.shift(); | ||
}, | ||
empty: function() { | ||
return this.queue.length === 0; | ||
} | ||
} | ||
}; | ||
{ | ||
module.exports = dijkstra; | ||
} | ||
}); | ||
var PriorityQueue = dijkstra_1.PriorityQueue; | ||
export default dijkstra_1; | ||
var extract_shortest_path_from_predecessor_list = dijkstra_1.extract_shortest_path_from_predecessor_list; | ||
var find_path = dijkstra_1.find_path; | ||
var single_source_shortest_paths = dijkstra_1.single_source_shortest_paths; | ||
export {PriorityQueue, dijkstra_1 as __moduleExports, extract_shortest_path_from_predecessor_list, find_path, single_source_shortest_paths}; |
39 changes: 39 additions & 0 deletions
39
...encode-utf8@v1.0.3-DnKGEsaBpFaYTp6Pp8vc/dist=es2019,mode=imports/optimized/encode-utf8.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var encodeUtf8 = function encodeUtf82(input) { | ||
var result = []; | ||
var size = input.length; | ||
for (var index = 0; index < size; index++) { | ||
var point = input.charCodeAt(index); | ||
if (point >= 55296 && point <= 56319 && size > index + 1) { | ||
var second = input.charCodeAt(index + 1); | ||
if (second >= 56320 && second <= 57343) { | ||
point = (point - 55296) * 1024 + second - 56320 + 65536; | ||
index += 1; | ||
} | ||
} | ||
if (point < 128) { | ||
result.push(point); | ||
continue; | ||
} | ||
if (point < 2048) { | ||
result.push(point >> 6 | 192); | ||
result.push(point & 63 | 128); | ||
continue; | ||
} | ||
if (point < 55296 || point >= 57344 && point < 65536) { | ||
result.push(point >> 12 | 224); | ||
result.push(point >> 6 & 63 | 128); | ||
result.push(point & 63 | 128); | ||
continue; | ||
} | ||
if (point >= 65536 && point <= 1114111) { | ||
result.push(point >> 18 | 240); | ||
result.push(point >> 12 & 63 | 128); | ||
result.push(point >> 6 & 63 | 128); | ||
result.push(point & 63 | 128); | ||
continue; | ||
} | ||
result.push(239, 191, 189); | ||
} | ||
return new Uint8Array(result).buffer; | ||
}; | ||
export default encodeUtf8; |
Oops, something went wrong.