Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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 () {
Expand All @@ -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 () {
Expand All @@ -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 () {
Expand All @@ -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) {
Expand Down