Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ngraph.coarsen

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngraph.coarsen - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

3

index.js

@@ -47,4 +47,5 @@ var createGraph = require('ngraph.graph');

// we don't care which node will represent isolated community.
isolateCommunityId = node.id;
isolateCommunityId = nodeCommunity;
}
isolateNodes.add(node.id);

@@ -51,0 +52,0 @@ });

{
"name": "ngraph.coarsen",
"version": "1.1.0",
"version": "1.2.0",
"description": "Given a community structure creates a coarse graph",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -94,3 +94,2 @@ var coarsen = require('../');

getClass: function getClass(nodeId) {
// now we pretend that if nodes are odd - they belong to the same community:
return (nodeId < 3) ? 1 : 2;

@@ -105,8 +104,34 @@ }

var node = newGraph.getNode(2);
t.equals(newGraph.getNodesCount(), 2, 'There are two nodes');
t.ok(node.data.has(3) && node.data.has(4), 'The isolate community lists all nodes');
t.end();
});
test('it does not mix node ids with community ids', function(t) {
var srcGraph = createGraph();
srcGraph.addLink(1, 2);
srcGraph.addNode(3);
srcGraph.addNode(4);
var fakeCommunity = {
getClass: function getClass(nodeId) {
// communityId 3 is assigned to nodes 1 and 2.
// Note however that we also have a node with id 3.
return (nodeId < 3) ? 3 : 2;
}
}
var newGraph = coarsen(srcGraph, fakeCommunity);
var selfLink = newGraph.getLink(3, 3);
t.equals(newGraph.getLinksCount(), 1, 'There should be one link');
t.ok(selfLink, 'and that is self link');
// the isolate nodes are assigned at random:
var node = newGraph.getNode(3) || newGraph.getNode(4);
var node = newGraph.getNode(2);
t.equals(newGraph.getNodesCount(), 2, 'There are two nodes');
t.ok(node.data.has(3) && node.data.has(4), 'The isolate community lits all nodes');
t.ok(node.data.has(3) && node.data.has(4), 'The isolate community lists all nodes');
t.end();
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc