ngraph.coarsen
Advanced tools
Comparing version 1.2.0 to 1.3.0
var createGraph = require('ngraph.graph'); | ||
module.exports = coarsen; | ||
module.exports.getSubgraphs = require('./lib/getSubgraphs.js'); | ||
@@ -54,3 +55,3 @@ function coarsen(srcGraph, community) { | ||
if (isolateNodes.size > 0) { | ||
// Each node in the isolated noes has no links. So they all belong to the | ||
// Each node in the isolated nodes has no links. So they all belong to the | ||
// same community. We take arbitrary node from this class and assign them | ||
@@ -61,2 +62,4 @@ // all to the same community: | ||
graph.srcGraph = srcGraph; | ||
return graph; | ||
@@ -63,0 +66,0 @@ |
{ | ||
"name": "ngraph.coarsen", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Given a community structure creates a coarse graph", | ||
@@ -24,3 +24,6 @@ "main": "index.js", | ||
"tap": "^5.7.1" | ||
}, | ||
"dependencies": { | ||
"ngraph.subgraph": "^1.0.0" | ||
} | ||
} |
@@ -136,1 +136,39 @@ var coarsen = require('../'); | ||
}); | ||
test('it adds srcGraph to response', function(t) { | ||
var srcGraph = createGraph(); | ||
srcGraph.addLink(1, 2); | ||
srcGraph.addNode(3); | ||
srcGraph.addNode(4); | ||
var fakeCommunity = { | ||
getClass: function getClass(nodeId) { | ||
return (nodeId < 3) ? 3 : 2; | ||
} | ||
} | ||
var newGraph = coarsen(srcGraph, fakeCommunity); | ||
t.equals(newGraph.srcGraph, srcGraph, 'srcGraph is here.'); | ||
t.end(); | ||
}); | ||
test('it can get all subgraphs', function(t) { | ||
var srcGraph = createGraph(); | ||
srcGraph.addLink(1, 2); | ||
srcGraph.addNode(3); | ||
srcGraph.addNode(4); | ||
var fakeCommunity = { | ||
getClass: function getClass(nodeId) { | ||
return (nodeId < 3) ? 3 : 2; | ||
} | ||
} | ||
var coarseGraph = coarsen(srcGraph, fakeCommunity); | ||
var allGraphs = coarsen.getSubgraphs(coarseGraph); | ||
t.equals(allGraphs.length, 2, 'Two communities - two graphs'); | ||
t.end(); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10378
7
212
1
+ Addedngraph.subgraph@^1.0.0
+ Addedngraph.events@1.2.2(transitive)
+ Addedngraph.graph@20.0.1(transitive)
+ Addedngraph.subgraph@1.2.0(transitive)