Skip to content

Commit

Permalink
feat: export Cluster class (#13)
Browse files Browse the repository at this point in the history
The Cluster class has several methods that are useful with clustering results created independently from the agnes method.
  • Loading branch information
zbjornson authored Sep 19, 2021
1 parent 9b2a71c commit 893fb96
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion hclust.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface AgnesOptions<T> {
// distanceFunction?: (a: T, b: T) => number;
// }

export interface Cluster {
export class Cluster {
children: Cluster[];
height: number;
size: number;
Expand Down
8 changes: 6 additions & 2 deletions src/__tests__/cluster.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as data from '../../testData';

import { agnes } from '..';
import { agnes, Cluster } from '..';

test('size', () => {
const clust = agnes(data.features1);
Expand Down Expand Up @@ -44,3 +43,8 @@ test('traverse, isLeaf and index', () => {
expect(other).toBe(9);
expect(leaves).toBe(10);
});

test('class access', () => {
const clust = new Cluster();
expect(clust.children).toStrictEqual([]);
});
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './agnes';
// export * from './birch';
// export * './cure';
// export * from './chameleon';
export { default as Cluster } from './Cluster';

0 comments on commit 893fb96

Please sign in to comment.