How to use the graphlib.data function in graphlib

To help you get started, we’ve selected a few graphlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tylingsoft / dagre-layout / lib / algo / prim.js View on Github external
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;
  }