Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
});