X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Fevoinference%2Fdistance%2FNeighborJoining.java;h=c624bfff21f3dabe41e904e4a7d5028e2faa9b9e;hb=391381d661a230af98751dd6eba77bb2353c4d3e;hp=164599de97d981fd1b7427941ece0ef52f98b46c;hpb=5a79605dde82b956c0cf429dd016c3b478012f9c;p=jalview.git diff --git a/forester/java/src/org/forester/evoinference/distance/NeighborJoining.java b/forester/java/src/org/forester/evoinference/distance/NeighborJoining.java index 164599d..c624bff 100644 --- a/forester/java/src/org/forester/evoinference/distance/NeighborJoining.java +++ b/forester/java/src/org/forester/evoinference/distance/NeighborJoining.java @@ -21,7 +21,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA // // Contact: phylosoft @ gmail . com -// WWW: www.phylosoft.org/forester +// WWW: https://sites.google.com/site/cmzmasek/home/software/forester package org.forester.evoinference.distance; @@ -36,7 +36,7 @@ import org.forester.util.ForesterUtil; public final class NeighborJoining { private BasicSymmetricalDistanceMatrix _d; - private BasicSymmetricalDistanceMatrix _m; + // private BasicSymmetricalDistanceMatrix _m; private double[][] _d_values; private double[][] _m_values; private double[] _r; @@ -60,7 +60,7 @@ public final class NeighborJoining { } // _d_values[ _mappings[ otu1 ] ][ _mappings[ i ] ] = ( getValueFromD( otu1, i ) + getValueFromD( i, otu2 ) - d ) / 2; i_m = _mappings[ i ]; - _d_values[ otu1_m ][ i_m ] = ( _d_values[ otu1_m ][ i_m ] + _d_values[ i_m ][ otu2_m ] - 2 ) / 2; + _d_values[ otu1_m ][ i_m ] = ( ( _d_values[ otu1_m ][ i_m ] + _d_values[ i_m ][ otu2_m ] ) - 2 ) / 2; } } @@ -178,11 +178,10 @@ public final class NeighborJoining { private final void reset( final BasicSymmetricalDistanceMatrix distances ) { _n = distances.getSize(); _d = distances; - _m = new BasicSymmetricalDistanceMatrix( _n ); _r = new double[ _n ]; _mappings = new int[ _n ]; _d_values = _d.getValues(); - _m_values = _m.getValues(); + _m_values = new double[ _n ][ _n ]; initExternalNodes(); } @@ -196,14 +195,14 @@ public final class NeighborJoining { j_m = _mappings[ j ]; for( int i = 0; i < j; ++i ) { // _m_values[ i ][ j ] = getValueFromD( i, j ) - ( _r[ i ] + r_j ) / ( _n - 2 ); - _m_values[ i ][ j ] = _d_values[ _mappings[ i ] ][ j_m ] - ( _r[ i ] + r_j ) / ( _n_2 ); + _m_values[ i ][ j ] = _d_values[ _mappings[ i ] ][ j_m ] - ( ( _r[ i ] + r_j ) / ( _n_2 ) ); } } } // otu2 will, in effect, be "deleted" from the matrix. private final void updateMappings( final int otu2 ) { - for( int i = otu2; i < _mappings.length - 1; ++i ) { + for( int i = otu2; i < ( _mappings.length - 1 ); ++i ) { _mappings[ i ] = _mappings[ i + 1 ]; } }