graphology
Advanced tools
Comparing version 0.22.2 to 0.23.0
{ | ||
"name": "graphology", | ||
"version": "0.22.2", | ||
"version": "0.23.0", | ||
"description": "A robust and multipurpose Graph object for JavaScript.", | ||
@@ -15,3 +15,3 @@ "main": "dist/graphology.cjs.js", | ||
"test": "mocha -u exports --require @babel/register ./test.js", | ||
"test:types": "tsc --lib es2015,dom --noEmit --noImplicitAny --noImplicitReturns ./test-types.ts" | ||
"test:types": "tsc --lib es2015,dom --noEmit --noImplicitAny --noImplicitReturns --strictNullChecks ./test-types.ts" | ||
}, | ||
@@ -57,3 +57,3 @@ "files": [ | ||
"peerDependencies": { | ||
"graphology-types": ">=0.21.0" | ||
"graphology-types": ">=0.23.0" | ||
}, | ||
@@ -60,0 +60,0 @@ "babel": { |
@@ -20,4 +20,2 @@ "use strict"; | ||
var METHODS = ['getNodeAttribute', 'getNodeAttributes', 'hasNodeAttribute', 'getEdgeAttribute', 'getEdgeAttributes', 'hasEdgeAttribute', 'setNodeAttribute', 'setEdgeAttribute', 'updateNodeAttribute', 'updateEdgeAttribute', 'removeNodeAttribute', 'removeEdgeAttribute', 'replaceNodeAttributes', 'replaceEdgeAttributes', 'mergeNodeAttributes', 'mergeEdgeAttributes']; | ||
function attributes(Graph, checkers) { | ||
@@ -31,3 +29,3 @@ var invalid = checkers.invalid, | ||
'it should throw if the given path is not found.': function itShouldThrowIfTheGivenPathIsNotFound() { | ||
if (!~method.indexOf('Edge')) return; | ||
if (!method.includes('Edge')) return; | ||
var graph = new Graph(); | ||
@@ -40,3 +38,3 @@ | ||
'it should throw when using a path on a multi graph.': function itShouldThrowWhenUsingAPathOnAMultiGraph() { | ||
if (!~method.indexOf('Edge')) return; | ||
if (!method.includes('Edge')) return; | ||
var graph = new Graph({ | ||
@@ -61,3 +59,6 @@ multi: true | ||
var tests = {}; | ||
METHODS.forEach(function (method) { | ||
var relevantMethods = Object.keys(Graph.prototype).filter(function (name) { | ||
return (name.includes('NodeAttribute') || name.includes('EdgeAttribute') || name.includes('SourceAttribute') || name.includes('TargetAttribute') || name.includes('OppositeAttribute')) && !name.includes('Each'); | ||
}); | ||
relevantMethods.forEach(function (method) { | ||
return (0, _helpers.deepMerge)(tests, commonTests(method)); | ||
@@ -95,2 +96,64 @@ }); | ||
}, | ||
'#.getSourceAttribute': { | ||
'it should return the correct value.': function itShouldReturnTheCorrectValue() { | ||
var graph = new Graph(); | ||
graph.addNode('Martha', { | ||
age: 34 | ||
}); | ||
var _graph$mergeEdge = graph.mergeEdge('Martha', 'Riwan'), | ||
edge = _graph$mergeEdge[0]; | ||
_assert["default"].strictEqual(graph.getSourceAttribute(edge, 'age'), 34); | ||
}, | ||
'it should return undefined if the attribute does not exist.': function itShouldReturnUndefinedIfTheAttributeDoesNotExist() { | ||
var graph = new Graph(); | ||
graph.addNode('Martha'); | ||
var _graph$mergeEdge2 = graph.mergeEdge('Martha', 'Riwan'), | ||
edge = _graph$mergeEdge2[0]; | ||
_assert["default"].strictEqual(graph.getSourceAttribute(edge, 'age'), undefined); | ||
} | ||
}, | ||
'#.getTargetAttribute': { | ||
'it should return the correct value.': function itShouldReturnTheCorrectValue() { | ||
var graph = new Graph(); | ||
graph.addNode('Martha', { | ||
age: 34 | ||
}); | ||
var _graph$mergeEdge3 = graph.mergeEdge('Riwan', 'Martha'), | ||
edge = _graph$mergeEdge3[0]; | ||
_assert["default"].strictEqual(graph.getTargetAttribute(edge, 'age'), 34); | ||
}, | ||
'it should return undefined if the attribute does not exist.': function itShouldReturnUndefinedIfTheAttributeDoesNotExist() { | ||
var graph = new Graph(); | ||
graph.addNode('Martha'); | ||
var _graph$mergeEdge4 = graph.mergeEdge('Riwan', 'Martha'), | ||
edge = _graph$mergeEdge4[0]; | ||
_assert["default"].strictEqual(graph.getTargetAttribute(edge, 'age'), undefined); | ||
} | ||
}, | ||
'#.getOppositeAttribute': { | ||
'it should return the correct value.': function itShouldReturnTheCorrectValue() { | ||
var graph = new Graph(); | ||
graph.addNode('Martha', { | ||
age: 34 | ||
}); | ||
graph.addNode('Riwan', { | ||
age: 25 | ||
}); | ||
var _graph$mergeEdge5 = graph.mergeEdge('Riwan', 'Martha'), | ||
edge = _graph$mergeEdge5[0]; | ||
_assert["default"].strictEqual(graph.getOppositeAttribute('Riwan', edge, 'age'), 34); | ||
_assert["default"].strictEqual(graph.getOppositeAttribute('Martha', edge, 'age'), 25); | ||
} | ||
}, | ||
'#.getEdgeAttribute': { | ||
@@ -283,12 +346,2 @@ 'it should return the correct value.': function itShouldReturnTheCorrectValue() { | ||
'#.setNodeAttribute': { | ||
'it should throw if not enough arguments are provided.': function itShouldThrowIfNotEnoughArgumentsAreProvided() { | ||
var graph = new Graph(); | ||
graph.addNode('Lucy'); | ||
_assert["default"]["throws"](function () { | ||
graph.setNodeAttribute('Lucy', { | ||
hello: 'world' | ||
}); | ||
}, invalid()); | ||
}, | ||
"it should correctly set the node's attribute.": function itShouldCorrectlySetTheNodeSAttribute() { | ||
@@ -514,6 +567,9 @@ var graph = new Graph(); | ||
var graph = new Graph(); | ||
var edge = graph.mergeEdge('John', 'Martha', { | ||
var _graph$mergeEdge6 = graph.mergeEdge('John', 'Martha', { | ||
weight: 1, | ||
size: 3 | ||
}); | ||
}), | ||
edge = _graph$mergeEdge6[0]; | ||
graph.removeEdgeAttribute('John', 'Martha', 'weight'); | ||
@@ -738,2 +794,109 @@ graph.removeEdgeAttribute(edge, 'size'); | ||
}, | ||
'#.updateAttributes': { | ||
'it should throw if given updater is not a function.': function itShouldThrowIfGivenUpdaterIsNotAFunction() { | ||
var graph = new Graph(); | ||
_assert["default"]["throws"](function () { | ||
graph.updateAttribute(true); | ||
}, invalid()); | ||
}, | ||
'it should correctly update attributes.': function itShouldCorrectlyUpdateAttributes() { | ||
var graph = new Graph(); | ||
graph.setAttribute('name', 'graph'); | ||
graph.updateAttributes(function (attr) { | ||
return _objectSpread(_objectSpread({}, attr), {}, { | ||
color: 'blue' | ||
}); | ||
}); | ||
_assert["default"].deepStrictEqual(graph.getAttributes(), { | ||
name: 'graph', | ||
color: 'blue' | ||
}); | ||
} | ||
}, | ||
'#.updateNodeAttributes': { | ||
'it should throw if given updater is not a function': function itShouldThrowIfGivenUpdaterIsNotAFunction() { | ||
var graph = new Graph(); | ||
graph.addNode('John'); | ||
_assert["default"]["throws"](function () { | ||
graph.updateNodeAttributes('John', true); | ||
}, invalid()); | ||
}, | ||
'it should correctly update attributes.': function itShouldCorrectlyUpdateAttributes() { | ||
var graph = new Graph(); | ||
graph.addNode('John', { | ||
age: 45 | ||
}); | ||
graph.updateNodeAttributes('John', function (attr) { | ||
return _objectSpread(_objectSpread({}, attr), {}, { | ||
eyes: 'blue' | ||
}); | ||
}); | ||
_assert["default"].deepStrictEqual(graph.getNodeAttributes('John'), { | ||
age: 45, | ||
eyes: 'blue' | ||
}); | ||
} | ||
}, | ||
'#.updateEdgeAttributes': { | ||
'it should throw if given updater is not a function.': function itShouldThrowIfGivenUpdaterIsNotAFunction() { | ||
var graph = new Graph(); | ||
(0, _helpers.addNodesFrom)(graph, ['John', 'Martha']); | ||
var edge = graph.addEdge('John', 'Martha'); | ||
_assert["default"]["throws"](function () { | ||
graph.updateEdgeAttributes(edge, true); | ||
}, invalid()); | ||
}, | ||
'it should also work with typed edges.': function itShouldAlsoWorkWithTypedEdges() { | ||
var graph = new Graph(); | ||
(0, _helpers.addNodesFrom)(graph, ['John', 'Thomas']); | ||
graph.addDirectedEdge('John', 'Thomas', { | ||
test: 0 | ||
}); | ||
graph.addUndirectedEdge('John', 'Thomas', { | ||
test: 0 | ||
}); | ||
graph.updateDirectedEdgeAttributes('John', 'Thomas', function (attr) { | ||
return _objectSpread(_objectSpread({}, attr), {}, { | ||
weight: 2 | ||
}); | ||
}); | ||
graph.updateUndirectedEdgeAttributes('John', 'Thomas', function (attr) { | ||
return _objectSpread(_objectSpread({}, attr), {}, { | ||
weight: 3 | ||
}); | ||
}); | ||
_assert["default"].deepStrictEqual(graph.getDirectedEdgeAttributes('John', 'Thomas'), { | ||
weight: 2, | ||
test: 0 | ||
}); | ||
_assert["default"].deepStrictEqual(graph.getUndirectedEdgeAttributes('John', 'Thomas'), { | ||
weight: 3, | ||
test: 0 | ||
}); | ||
}, | ||
'it should correctly update attributes.': function itShouldCorrectlyUpdateAttributes() { | ||
var graph = new Graph(); | ||
(0, _helpers.addNodesFrom)(graph, ['John', 'Martha']); | ||
var edge = graph.addEdge('John', 'Martha', { | ||
weight: 1 | ||
}); | ||
graph.updateEdgeAttributes(edge, function (attr) { | ||
return _objectSpread(_objectSpread({}, attr), {}, { | ||
type: 'KNOWS' | ||
}); | ||
}); | ||
_assert["default"].deepStrictEqual(graph.getEdgeAttributes(edge), { | ||
weight: 1, | ||
type: 'KNOWS' | ||
}); | ||
} | ||
}, | ||
'#.updateEachNodeAttributes': { | ||
@@ -811,3 +974,7 @@ 'it should throw when given invalid arguments.': function itShouldThrowWhenGivenInvalidArguments() { | ||
}); | ||
graph.updateEachEdgeAttributes(function (edge, attr) { | ||
graph.updateEachEdgeAttributes(function (edge, attr, source, _t, _sa, _ta, undirected) { | ||
_assert["default"].strictEqual(source, 'John'); | ||
_assert["default"].strictEqual(undirected, false); | ||
return _objectSpread(_objectSpread({}, attr), {}, { | ||
@@ -818,4 +985,4 @@ weight: attr.weight + 1 | ||
_assert["default"].deepStrictEqual(graph.edges().map(function (n) { | ||
return graph.getEdgeAttributes(n); | ||
_assert["default"].deepStrictEqual(graph.mapEdges(function (_, attr) { | ||
return attr; | ||
}), [{ | ||
@@ -822,0 +989,0 @@ weight: 2 |
@@ -10,4 +10,2 @@ "use strict"; | ||
var _take = _interopRequireDefault(require("obliterator/take")); | ||
var _nodes = _interopRequireDefault(require("./nodes")); | ||
@@ -30,172 +28,130 @@ | ||
Adjacency: { | ||
"it should be possible to iterate over the graph's adjacency using callbacks.": function itShouldBePossibleToIterateOverTheGraphSAdjacencyUsingCallbacks() { | ||
var graph = new Graph(); | ||
graph.addNode(1); | ||
graph.addNode(2); | ||
graph.addNode(3); | ||
graph.addEdge(1, 2); | ||
graph.addEdge(2, 3); | ||
graph.addEdge(3, 1); | ||
graph.addUndirectedEdge(1, 2); | ||
graph.replaceNodeAttributes(2, { | ||
hello: 'world' | ||
}); | ||
var adjacency = []; | ||
graph.forEach(function (s, t, sa, ta, e, ea, u) { | ||
adjacency.push([u, s, t]); | ||
'#.forEachAdjacencyEntry': { | ||
'it should iterate over the relevant elements.': function itShouldIterateOverTheRelevantElements() { | ||
function test(multi) { | ||
var graph = new Graph({ | ||
multi: multi | ||
}); | ||
graph.addNode('John', { | ||
hello: 'world' | ||
}); | ||
_assert["default"].deepStrictEqual(sa, graph.getNodeAttributes(s)); | ||
var _graph$mergeUndirecte = graph.mergeUndirectedEdge('John', 'Mary', { | ||
weight: 3 | ||
}), | ||
e1 = _graph$mergeUndirecte[0]; | ||
_assert["default"].deepStrictEqual(ta, graph.getNodeAttributes(t)); | ||
graph.mergeUndirectedEdge('Thomas', 'John'); | ||
graph.mergeDirectedEdge('John', 'Thomas'); | ||
var count = 0; | ||
graph.forEachAdjacencyEntry(function (node, neighbor, attr, neighborAttr, edge, edgeAttr, undirected) { | ||
count++; | ||
_assert["default"].deepStrictEqual(ea, graph.getEdgeAttributes(e)); | ||
if (node === 'John') { | ||
_assert["default"].deepStrictEqual(attr, { | ||
hello: 'world' | ||
}); | ||
} else { | ||
_assert["default"].deepStrictEqual(attr, {}); | ||
} | ||
_assert["default"].strictEqual(graph.isUndirected(e), u); | ||
}); | ||
if (neighbor === 'John') { | ||
_assert["default"].deepStrictEqual(neighborAttr, { | ||
hello: 'world' | ||
}); | ||
} else { | ||
_assert["default"].deepStrictEqual(neighborAttr, {}); | ||
} | ||
_assert["default"].deepStrictEqual(adjacency, [[false, '1', '2'], [true, '1', '2'], [false, '2', '3'], [true, '2', '1'], [false, '3', '1']]); | ||
}, | ||
"it should be possible to iterate over a multi graph's adjacency using callbacks.": function itShouldBePossibleToIterateOverAMultiGraphSAdjacencyUsingCallbacks() { | ||
var graph = new Graph({ | ||
multi: true | ||
}); | ||
graph.addNode(1); | ||
graph.addNode(2); | ||
graph.addNode(3); | ||
graph.addEdge(1, 2); | ||
graph.addEdge(2, 3); | ||
graph.addEdge(3, 1); | ||
graph.addEdgeWithKey('test', 2, 3); | ||
graph.addUndirectedEdge(1, 2); | ||
graph.replaceNodeAttributes(2, { | ||
hello: 'world' | ||
}); | ||
var adjacency = []; | ||
graph.forEach(function (s, t, sa, ta, e, ea, u) { | ||
adjacency.push([u, s, t]); | ||
if (edge === e1) { | ||
_assert["default"].deepStrictEqual(edgeAttr, { | ||
weight: 3 | ||
}); | ||
} else { | ||
_assert["default"].deepStrictEqual(edgeAttr, {}); | ||
} | ||
_assert["default"].deepStrictEqual(sa, graph.getNodeAttributes(s)); | ||
_assert["default"].strictEqual(graph.isUndirected(edge), undirected); | ||
}); | ||
_assert["default"].deepStrictEqual(ta, graph.getNodeAttributes(t)); | ||
_assert["default"].strictEqual(count, graph.directedSize + graph.undirectedSize * 2); | ||
_assert["default"].deepStrictEqual(ea, graph.getEdgeAttributes(e)); | ||
graph.addNode('Disconnected'); | ||
count = 0; | ||
graph.forEachAdjacencyEntryWithOrphans(function (node, neighbor, attr, neighborAttr, edge, edgeAttr, undirected) { | ||
count++; | ||
if (node !== 'Disconnected') return; | ||
_assert["default"].strictEqual(graph.isUndirected(e), u); | ||
}); | ||
_assert["default"].strictEqual(neighbor, null); | ||
_assert["default"].deepStrictEqual(adjacency, [[false, '1', '2'], [true, '1', '2'], [false, '2', '3'], [false, '2', '3'], [true, '2', '1'], [false, '3', '1']]); | ||
}, | ||
'it should be possible to find an edge in the adjacency.': function itShouldBePossibleToFindAnEdgeInTheAdjacency() { | ||
var graph = new Graph(); | ||
graph.addNode(1); | ||
graph.addNode(2); | ||
graph.addNode(3); | ||
graph.addEdge(1, 2); | ||
graph.addEdge(2, 3); | ||
graph.addEdge(3, 1); | ||
graph.addUndirectedEdge(1, 2); | ||
graph.replaceNodeAttributes(2, { | ||
hello: 'world' | ||
}); | ||
var adjacency = []; | ||
var found = graph.find(function (s, t, sa, ta, e, ea, u) { | ||
adjacency.push([u, s, t]); | ||
_assert["default"].strictEqual(neighborAttr, null); | ||
_assert["default"].deepStrictEqual(sa, graph.getNodeAttributes(s)); | ||
_assert["default"].strictEqual(edge, null); | ||
_assert["default"].deepStrictEqual(ta, graph.getNodeAttributes(t)); | ||
_assert["default"].strictEqual(edgeAttr, null); | ||
_assert["default"].deepStrictEqual(ea, graph.getEdgeAttributes(e)); | ||
_assert["default"].strictEqual(undirected, null); | ||
}, true); | ||
_assert["default"].strictEqual(graph.isUndirected(e), u); | ||
_assert["default"].strictEqual(count, graph.directedSize + graph.undirectedSize * 2 + 1); | ||
} | ||
if (sa.hello === 'world') return true; | ||
}); | ||
test(false); | ||
test(true); | ||
} | ||
}, | ||
'#.forEachAssymetricAdjacencyEntry': { | ||
'it should iterate over the relevant elements.': function itShouldIterateOverTheRelevantElements() { | ||
function test(multi) { | ||
var graph = new Graph({ | ||
multi: multi | ||
}); | ||
graph.addNode('John', { | ||
hello: 'world' | ||
}); | ||
graph.mergeUndirectedEdge('John', 'Mary', { | ||
weight: 3 | ||
}); | ||
graph.mergeUndirectedEdge('Thomas', 'John'); | ||
graph.mergeDirectedEdge('John', 'Thomas'); | ||
var edges = []; | ||
graph.forEachAssymetricAdjacencyEntry(function (node, neighbor, attr, neighborAttr, edge, edgeAttr, undirected) { | ||
if (undirected) { | ||
_assert["default"].strictEqual(node < neighbor, true); | ||
} | ||
_assert["default"].strictEqual(found, graph.edge(2, 3)); | ||
edges.push(edge); | ||
}); | ||
_assert["default"].deepStrictEqual(adjacency, [[false, '1', '2'], [true, '1', '2'], [false, '2', '3']]); | ||
_assert["default"].strictEqual(edges.length, graph.directedSize + graph.undirectedSize); | ||
found = graph.find(function () { | ||
return false; | ||
}); | ||
_assert["default"].deepStrictEqual(new Set(edges).size, edges.length); | ||
_assert["default"].strictEqual(found, undefined); | ||
}, | ||
"it should be possible to create an iterator over the graph's adjacency.": function itShouldBePossibleToCreateAnIteratorOverTheGraphSAdjacency() { | ||
var graph = new Graph(); | ||
graph.addNode(1); | ||
graph.addNode(2); | ||
graph.addNode(3); | ||
graph.addEdge(1, 2); | ||
graph.addEdge(2, 3); | ||
graph.addEdge(3, 1); | ||
graph.addUndirectedEdge(1, 2); | ||
graph.replaceNodeAttributes(2, { | ||
hello: 'world' | ||
}); | ||
var adj = (0, _take["default"])(graph.adjacency()).map(function (_ref) { | ||
var source = _ref.source, | ||
target = _ref.target, | ||
undirected = _ref.undirected; | ||
return [source, target, undirected]; | ||
}); | ||
graph.addNode('Disconnected'); | ||
var count = 0; | ||
var nulls = 0; | ||
graph.forEachAssymetricAdjacencyEntryWithOrphans(function (node, neighbor, attr, neighborAttr, edge, edgeAttr, undirected) { | ||
count++; | ||
if (neighbor) return; | ||
nulls++; | ||
_assert["default"].deepStrictEqual(adj, [['1', '2', false], ['1', '2', true], ['2', '3', false], ['2', '1', true], ['3', '1', false]]); | ||
}, | ||
"it should be possible to create an iterator over a multi graph's adjacency.": function itShouldBePossibleToCreateAnIteratorOverAMultiGraphSAdjacency() { | ||
var graph = new Graph({ | ||
multi: true | ||
}); | ||
graph.addNode(1); | ||
graph.addNode(2); | ||
graph.addNode(3); | ||
graph.addEdgeWithKey(0, 1, 2); | ||
graph.addEdgeWithKey(1, 2, 3); | ||
graph.addEdgeWithKey(2, 3, 1); | ||
graph.addEdgeWithKey(3, 2, 3); | ||
graph.addUndirectedEdgeWithKey(4, 1, 2); | ||
graph.replaceNodeAttributes(2, { | ||
hello: 'world' | ||
}); | ||
var adj = (0, _take["default"])(graph.adjacency()).map(function (_ref2) { | ||
var source = _ref2.source, | ||
target = _ref2.target, | ||
edge = _ref2.edge; | ||
return [source, target, edge]; | ||
}); | ||
_assert["default"].strictEqual(neighbor, null); | ||
_assert["default"].deepStrictEqual(adj, [['1', '2', '0'], ['1', '2', '4'], ['2', '3', '1'], ['2', '3', '3'], ['2', '1', '4'], ['3', '1', '2']]); | ||
}, | ||
'it should be possible to iterate via Symbol.iterator.': function itShouldBePossibleToIterateViaSymbolIterator() { | ||
if (typeof Symbol === 'undefined') return; | ||
_assert["default"].strictEqual(neighborAttr, null); | ||
var edgeKeyGenerator = function edgeKeyGenerator(_ref3) { | ||
var undirected = _ref3.undirected, | ||
source = _ref3.source, | ||
target = _ref3.target; | ||
return "".concat(source).concat(undirected ? '--' : '->').concat(target); | ||
}; | ||
_assert["default"].strictEqual(edge, null); | ||
var graph = new Graph({ | ||
edgeKeyGenerator: edgeKeyGenerator | ||
}); | ||
graph.addNode(1); | ||
graph.addNode(2); | ||
graph.addNode(3); | ||
graph.addEdge(1, 2); | ||
graph.addEdge(2, 3); | ||
graph.addEdge(3, 1); | ||
graph.addUndirectedEdge(1, 2); | ||
graph.replaceNodeAttributes(2, { | ||
hello: 'world' | ||
}); | ||
var adj = (0, _take["default"])(graph[Symbol.iterator]()).map(function (_ref4) { | ||
var source = _ref4.source, | ||
target = _ref4.target, | ||
undirected = _ref4.undirected; | ||
return [source, target, undirected]; | ||
}); | ||
_assert["default"].strictEqual(edgeAttr, null); | ||
_assert["default"].deepStrictEqual(adj, [['1', '2', false], ['1', '2', true], ['2', '3', false], ['2', '1', true], ['3', '1', false]]); | ||
_assert["default"].strictEqual(undirected, null); | ||
}, true); | ||
_assert["default"].strictEqual(count, graph.directedSize + graph.undirectedSize + 3); | ||
_assert["default"].strictEqual(nulls, 3); | ||
} | ||
test(false); | ||
test(true); | ||
} | ||
} | ||
@@ -202,0 +158,0 @@ }, |
@@ -84,2 +84,22 @@ "use strict"; | ||
}); | ||
}, | ||
'it should return useful information.': function itShouldReturnUsefulInformation() { | ||
var graph = new Graph(); | ||
var _graph$mergeNode = graph.mergeNode('Jack'), | ||
key = _graph$mergeNode[0], | ||
wasAdded = _graph$mergeNode[1]; | ||
_assert["default"].strictEqual(key, 'Jack'); | ||
_assert["default"].strictEqual(wasAdded, true); | ||
var _graph$mergeNode2 = graph.mergeNode('Jack'); | ||
key = _graph$mergeNode2[0]; | ||
wasAdded = _graph$mergeNode2[1]; | ||
_assert["default"].strictEqual(key, 'Jack'); | ||
_assert["default"].strictEqual(wasAdded, false); | ||
} | ||
@@ -139,2 +159,22 @@ }, | ||
}); | ||
}, | ||
'it should return useful information.': function itShouldReturnUsefulInformation() { | ||
var graph = new Graph(); | ||
var _graph$updateNode = graph.updateNode('Jack'), | ||
key = _graph$updateNode[0], | ||
wasAdded = _graph$updateNode[1]; | ||
_assert["default"].strictEqual(key, 'Jack'); | ||
_assert["default"].strictEqual(wasAdded, true); | ||
var _graph$updateNode2 = graph.updateNode('Jack'); | ||
key = _graph$updateNode2[0]; | ||
wasAdded = _graph$updateNode2[1]; | ||
_assert["default"].strictEqual(key, 'Jack'); | ||
_assert["default"].strictEqual(wasAdded, false); | ||
} | ||
@@ -370,2 +410,26 @@ }, | ||
_assert["default"].strictEqual(graph.size, 1); | ||
}, | ||
'it should return useful information.': function itShouldReturnUsefulInformation() { | ||
var graph = new Graph(); | ||
var info = graph.mergeEdge('John', 'Jack'); | ||
_assert["default"].deepStrictEqual(info, [graph.edge('John', 'Jack'), true, true, true]); | ||
info = graph.mergeEdge('John', 'Jack'); | ||
_assert["default"].deepStrictEqual(info, [graph.edge('John', 'Jack'), false, false, false]); | ||
graph.addNode('Mary'); | ||
info = graph.mergeEdge('Mary', 'Sue'); | ||
_assert["default"].deepStrictEqual(info, [graph.edge('Mary', 'Sue'), true, false, true]); | ||
info = graph.mergeEdge('Gwladys', 'Mary'); | ||
_assert["default"].deepStrictEqual(info, [graph.edge('Gwladys', 'Mary'), true, true, false]); | ||
graph.addNode('Quintin'); | ||
info = graph.mergeEdge('Quintin', 'Mary'); | ||
_assert["default"].deepStrictEqual(info, [graph.edge('Quintin', 'Mary'), true, false, false]); | ||
} | ||
@@ -475,2 +539,26 @@ }, | ||
_assert["default"].strictEqual(graph.size, 1); | ||
}, | ||
'it should return useful information.': function itShouldReturnUsefulInformation() { | ||
var graph = new Graph(); | ||
var info = graph.updateEdge('John', 'Jack'); | ||
_assert["default"].deepStrictEqual(info, [graph.edge('John', 'Jack'), true, true, true]); | ||
info = graph.updateEdge('John', 'Jack'); | ||
_assert["default"].deepStrictEqual(info, [graph.edge('John', 'Jack'), false, false, false]); | ||
graph.addNode('Mary'); | ||
info = graph.updateEdge('Mary', 'Sue'); | ||
_assert["default"].deepStrictEqual(info, [graph.edge('Mary', 'Sue'), true, false, true]); | ||
info = graph.updateEdge('Gwladys', 'Mary'); | ||
_assert["default"].deepStrictEqual(info, [graph.edge('Gwladys', 'Mary'), true, true, false]); | ||
graph.addNode('Quintin'); | ||
info = graph.updateEdge('Quintin', 'Mary'); | ||
_assert["default"].deepStrictEqual(info, [graph.edge('Quintin', 'Mary'), true, false, false]); | ||
} | ||
@@ -477,0 +565,0 @@ }, |
@@ -584,4 +584,6 @@ "use strict"; | ||
graph.addNode('Jack'); | ||
var edge = graph.mergeEdge('Thomas', 'Estelle'); | ||
var _graph$mergeEdge = graph.mergeEdge('Thomas', 'Estelle'), | ||
edge = _graph$mergeEdge[0]; | ||
_assert["default"].strictEqual(graph.hasExtremity(edge, 'Thomas'), true); | ||
@@ -588,0 +590,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
2383945
21669