fix a little error in logic of createGroups() method

This commit is contained in:
David MAECHLER 2020-04-04 21:06:34 +02:00
parent 0434e141e7
commit 98be16708b

View File

@ -55,7 +55,7 @@ let createGroups = function(distances) {
groups[i] = []; groups[i] = [];
} }
if(groups[i].indexOf(dist.first) && typeof alreadyInGroup[dist.first.id] === 'undefined') { if(!groups[i].indexOf(dist.first) && typeof alreadyInGroup[dist.first.id] === 'undefined') {
groups[i].push(dist.first); groups[i].push(dist.first);
alreadyInGroup [dist.first.id] = true; alreadyInGroup [dist.first.id] = true;
} }
@ -69,7 +69,7 @@ let createGroups = function(distances) {
continue; continue;
} }
if(groups[i].indexOf(dist.second) && typeof alreadyInGroup[dist.second.id] === 'undefined') { if(!groups[i].indexOf(dist.second) && typeof alreadyInGroup[dist.second.id] === 'undefined') {
groups[i].push(dist.second); groups[i].push(dist.second);
alreadyInGroup [dist.second.id] = true; alreadyInGroup [dist.second.id] = true;
} }