How to use the bindings.CommunityGraph function in bindings

To help you get started, we’ve selected a few bindings 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 anvaka / ngraph.louvain / native.js View on Github external
var CommunityGraph = require('bindings')('louvain').CommunityGraph;

module.exports = {
  fromNgraph: fromNgraph
};

function fromNgraph(ngraph) {
  var nodeCount = ngraph.getNodesCount();
  var nodeToIndexMap = new Map();
  var lastAvailable = 0;

  var communityGraph = new CommunityGraph(nodeCount);

  ngraph.forEachNode(function(node) {
    nodeToIndexMap.set(node.id, lastAvailable);
    lastAvailable += 1;
  });