Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var PriorityQueue = require("graphlib").data.PriorityQueue;
/*
* This algorithm uses undirected traversal to find a miminum spanning tree
* using the supplied weight function. The algorithm is described in
* Cormen, et al., "Introduction to Algorithms". The returned structure
* is an array of node id to an array of adjacent nodes.
*/
module.exports = function(g, weight) {
var result = {};
var parent = {};
var q = new PriorityQueue();
if (g.nodes().length === 0) {
return result;
}