Skip to content

Commit

Permalink
updating neighbor joining documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenweaver committed Sep 24, 2022
1 parent 635a38a commit 86974d4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/neighbor-join.js
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
Expand Down

0 comments on commit 86974d4

Please sign in to comment.