isomorphism
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -99,6 +99,18 @@ 'use strict'; | ||
var setMappingInPossibleMappings = function setMappingInPossibleMappings(possibleMappings, patternVertex, targetVertex) { | ||
var eliminatePossibility = function eliminatePossibility(targetVertex, row) { | ||
return (0, _ramda.filter)(function (possibleTarget) { | ||
return !(possibleTarget === targetVertex); | ||
}, row); | ||
}; | ||
var mapping = []; | ||
for (var i = 0; i < possibleMappings.length; i++) { | ||
var possibleMappingsForPatternVertex = possibleMappings[i]; | ||
mapping.push(i === patternVertex ? [targetVertex] : possibleMappingsForPatternVertex); | ||
if (i < patternVertex) { | ||
mapping.push(possibleMappingsForPatternVertex); | ||
} else if (i === patternVertex) { | ||
mapping.push([targetVertex]); | ||
} else { | ||
mapping.push(eliminatePossibility(targetVertex, possibleMappingsForPatternVertex)); | ||
} | ||
} | ||
@@ -105,0 +117,0 @@ return mapping; |
{ | ||
"name": "isomorphism", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Find subgraph isomorphisms with Ullman's 1976 algorithm.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -44,2 +44,40 @@ /* @flow */ | ||
it('Self-reference in target graph does not match three-cycle', function () { | ||
assert.deepEqual( | ||
allIsomorphismsForWeightedDigraphs( | ||
[ | ||
[[1,1]], | ||
[[2,1]], | ||
[[0,1]] | ||
], | ||
[ | ||
[], | ||
[[1,1]], | ||
[] | ||
], | ||
null | ||
), | ||
[] | ||
) | ||
}) | ||
it('Self-reference in target graph does not match three-chain', function () { | ||
assert.deepEqual( | ||
allIsomorphismsForWeightedDigraphs( | ||
[ | ||
[[1,1]], | ||
[[2,1]], | ||
[] | ||
], | ||
[ | ||
[], | ||
[[1,1]], | ||
[] | ||
], | ||
null | ||
), | ||
[] | ||
) | ||
}) | ||
}) | ||
@@ -227,2 +265,46 @@ | ||
it('Isomorphisms for three-chain pattern on ten-cycle with orphans', function () { | ||
assert.deepEqual( | ||
allIsomorphismsForDigraphs( | ||
[ | ||
[1], | ||
[2], | ||
[] | ||
], | ||
[ | ||
[], | ||
[2], | ||
[3], | ||
[4], | ||
[5], | ||
[6], | ||
[7], | ||
[8], | ||
[9], | ||
[11], | ||
[], | ||
[1], | ||
[], | ||
[], | ||
[], | ||
[], | ||
[] | ||
], | ||
null | ||
), | ||
[ | ||
[1,2,3], | ||
[2,3,4], | ||
[3,4,5], | ||
[4,5,6], | ||
[5,6,7], | ||
[6,7,8], | ||
[7,8,9], | ||
[8,9,11], | ||
[9,11,1], | ||
[11,1,2] | ||
] | ||
) | ||
}) | ||
}) |
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
22629
453