ngraph.subgraph
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -6,10 +6,10 @@ var createGraph = require('ngraph.graph'); | ||
/** | ||
* Returns only a subgraph of a srcGraph for a set of `nodeSet`. | ||
* Returns only a subgraph of a `srcGraph` for a set of `nodeSet`. | ||
* | ||
* @params {Set} nodeSet set of node identifiers that should be used in the | ||
* subgraph. Note: if srcGraph doesn't contain a node from this specified, an | ||
* subgraph. Note: if `srcGraph` doesn't contain a node from this set, an | ||
* exception is thrown. | ||
* @param {ngraph.graph} srcGraph - origianal graph. | ||
* @param {ngraph.graph} srcGraph - original graph. | ||
* | ||
* @returns {ngraph.graph} Graph object that has all nodes from a nodeSet. | ||
* @returns {ngraph.graph} Graph object that has all nodes from a `nodeSet`. | ||
*/ | ||
@@ -16,0 +16,0 @@ function getSubGraph(nodeSet, srcGraph) { |
{ | ||
"name": "ngraph.subgraph", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Builds a subgraph of a graph for a set of nodes", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "tap test/index.js" | ||
"test": "tap --branches=90 --lines=90 --statements=90 --functions=90 test/index.js" | ||
}, | ||
@@ -21,7 +21,7 @@ "keywords": [ | ||
"dependencies": { | ||
"ngraph.graph": "^18.0.0" | ||
"ngraph.graph": "^20.0.0" | ||
}, | ||
"devDependencies": { | ||
"tap": "^14.1.11" | ||
"tap": "^15.1.6" | ||
} | ||
} |
@@ -1,8 +0,8 @@ | ||
var test = require('tap').test; | ||
const test = require('tap').test; | ||
var getSubgraph = require('../'); | ||
var createGraph = require('ngraph.graph'); | ||
const getSubgraph = require('../'); | ||
const createGraph = require('ngraph.graph'); | ||
test('it can create a subset', function (t) { | ||
var srcGraph = createGraph(); | ||
const srcGraph = createGraph(); | ||
srcGraph.addNode(1, 'hello'); | ||
@@ -13,12 +13,12 @@ | ||
var g = getSubgraph(new Set([1, 2]), srcGraph); | ||
const g = getSubgraph(new Set([1, 2]), srcGraph); | ||
t.equals(g.getLinksCount(), 1, 'Only one link'); | ||
t.equal(g.getLinksCount(), 1, 'Only one link'); | ||
t.ok(g.hasLink(1, 2), 'link is correct'); | ||
t.equals(g.getLink(1, 2).data, 42, 'link data is correct'); | ||
t.equal(g.getLink(1, 2).data, 42, 'link data is correct'); | ||
t.equals(g.getNodesCount(), 2, 'Only two nodes'); | ||
t.equal(g.getNodesCount(), 2, 'Only two nodes'); | ||
t.ok(g.getNode(1), 'First node is here'); | ||
t.ok(g.getNode(2), 'Second node is here'); | ||
t.equals(g.getNode(1).data, 'hello', 'Second node is here'); | ||
t.equal(g.getNode(1).data, 'hello', 'Second node is here'); | ||
@@ -29,3 +29,3 @@ t.end(); | ||
test('it can handle isolated nodes', function (t) { | ||
var srcGraph = createGraph(); | ||
const srcGraph = createGraph(); | ||
srcGraph.addNode('a', 'hello'); | ||
@@ -36,12 +36,20 @@ | ||
var g = getSubgraph(new Set(['a', 'c']), srcGraph); | ||
const g = getSubgraph(new Set(['a', 'c']), srcGraph); | ||
t.equals(g.getLinksCount(), 0, 'No lihnks'); | ||
t.equals(g.getNodesCount(), 2, 'Only two nodes'); | ||
t.equal(g.getLinksCount(), 0, 'No links'); | ||
t.equal(g.getNodesCount(), 2, 'Only two nodes'); | ||
t.ok(g.getNode('a'), 'First node is here'); | ||
t.ok(g.getNode('c'), 'Second node is here'); | ||
t.equals(g.getNode('a').data, 'hello', 'Second node is here'); | ||
t.equal(g.getNode('a').data, 'hello', 'Second node is here'); | ||
t.end(); | ||
}); | ||
test('it throws on absent node', t => { | ||
const srcGraph = createGraph(); | ||
srcGraph.addNode(1, 'hello'); | ||
t.throws(() => getSubgraph(new Set([2]), srcGraph), 'No such node'); | ||
t.end(); | ||
}); |
Sorry, the diff of this file is not supported yet
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
5127
6
63
+ Addedngraph.events@1.2.2(transitive)
+ Addedngraph.graph@20.0.1(transitive)
- Removedngraph.events@1.0.0(transitive)
- Removedngraph.graph@18.0.3(transitive)
Updatedngraph.graph@^20.0.0