From 8ade5f508df5e24acab883787c3f81d426fac423 Mon Sep 17 00:00:00 2001 From: Yosuke ONOUE Date: Mon, 3 Aug 2015 16:23:11 +0900 Subject: [PATCH] Fix .from and .to --- lib/index.js | 4 ++-- test/test.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index f6a46c0..ff6c026 100644 --- a/lib/index.js +++ b/lib/index.js @@ -84,8 +84,8 @@ Cluster.prototype.reduce = function () { var level = { linkage: min.linkage, clusters: clusters, - from: j, - to: i, + from: min.j, + to: min.i, } this.levels.push(level) return level diff --git a/test/test.js b/test/test.js index aa79c5d..80fa551 100644 --- a/test/test.js +++ b/test/test.js @@ -25,6 +25,8 @@ describe('Colors', function () { var last = levels[levels.length - 1] assert(last.clusters.length === 1) assert(last.clusters[0].length === 7) + assert(last.from === 0) + assert(last.to === 1) }) it('should cluster (predefined single)', function () { @@ -37,6 +39,8 @@ describe('Colors', function () { var last = levels[levels.length - 1] assert(last.clusters.length === 1) assert(last.clusters[0].length === 7) + assert(last.from === 0) + assert(last.to === 1) }) it('should cluster (predefined complete)', function () { @@ -49,6 +53,8 @@ describe('Colors', function () { var last = levels[levels.length - 1] assert(last.clusters.length === 1) assert(last.clusters[0].length === 7) + assert(last.from === 0) + assert(last.to === 1) }) it('should cluster (predefined average)', function () { @@ -61,6 +67,8 @@ describe('Colors', function () { var last = levels[levels.length - 1] assert(last.clusters.length === 1) assert(last.clusters[0].length === 7) + assert(last.from === 0) + assert(last.to === 1) }) it('should support min clusters', function () { @@ -73,6 +81,8 @@ describe('Colors', function () { assert(levels.length === 5) var last = levels[levels.length - 1] assert(last.clusters.length === 3) + assert(last.from === 1) + assert(last.to === 2) // match it against the example last.clusters.forEach(function (cluster) {