From 86974d412be5b6e02539d2641c6269bede1e7f35 Mon Sep 17 00:00:00 2001 From: Steven Weaver Date: Fri, 23 Sep 2022 20:41:57 -0500 Subject: [PATCH] updating neighbor joining documentation --- src/neighbor-join.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/neighbor-join.js b/src/neighbor-join.js index 06cde36..d3d0423 100644 --- a/src/neighbor-join.js +++ b/src/neighbor-join.js @@ -82,6 +82,23 @@ function getTotalDistances(distanceMatrix) { return _.map(distanceMatrix, _.sum); } +/** + * Create a neighbor joining tree from a distance matrix + * See test/neighbor-join-test.js for a working example + * + * @param {Array} distanceMatrixArr The NxN distance matrix. + * const D = [ + * [0, 5, 9, 9, 8], + * [5, 0, 10, 10, 9], + * [9, 10, 0, 8, 7], + * [9, 10, 8, 0, 3], + * [8, 9, 7, 3, 0] + * ]; + * + * @param {Number} n The dimension of the distanceMatrixArr. + * @param {Array} nodeList The names of each row in the distanceMatrix + * @returns The neighbor joining new tree. + */ export default function neighborJoining(distanceMatrixArr, n, nodeList) { if (n <= 2) { let tree = new phylotree("");