import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
-import java.util.SortedSet;
+import java.util.Set;
import org.forester.evoinference.matrix.distance.BasicSymmetricalDistanceMatrix;
import org.forester.phylogeny.Phylogeny;
_umax = -1000;
for( int i = 0; i < _n; ++i ) {
_r[ i ] = calculateNetDivergence( i );
- if ( _r[i ] > _umax ) {
+ if ( _r[ i ] > _umax ) {
_umax = _r[i ];
}
}
System.out.print( " " );
}
System.out.print( "\t\t" );
- for( final Entry<Integer, SortedSet<Integer>> entry : _s.getSentrySet( _mappings[ j ] ) ) {
+ for( final Entry<Integer, Set<Integer>> entry : _s.getSentrySet( _mappings[ j ] ) ) {
System.out.print( DF.format( ( double ) entry.getKey() / S.FACTOR ) + "=" );
boolean first = true;
for( final int v : entry.getValue() ) {
if ( _verbose ) {
printM();
}
- for( int j = 1; j < _n; ++j ) {
+ J: for( int j = 1; j < _n; ++j ) {
final double r_j = _r[ j ];
final int m_j = _mappings[ j ];
if ( _verbose ) {
System.out.print( "j=" + j + " mj=" + m_j + ": " );
}
- X: for( final Entry<Integer, SortedSet<Integer>> entry : _s.getSentrySet( m_j ) ) {
+ for( final Entry<Integer, Set<Integer>> entry : _s.getSentrySet( m_j ) ) {
for( final int sorted_i : entry.getValue() ) {
final double m = _d_values[ sorted_i ][ m_j ]
- ( ( _r[ _rev_mappings[ sorted_i ] ] + r_j ) / n_minus_2 );
//final double m = getDvalueUnmapped( sorted_i, m_j )
// - ( ( _r[ _rev_mappings[ sorted_i ] ] + r_j ) / n_minus_2 );
- if ( m - r_j - _umax > min_m ) {
- System.out.println( m );
- continue X;
+ System.out.println( "m=" + m );
+ System.out.println( "r_j=" + r_j );
+ System.out.println( "umax=" + _umax );
+ System.out.println( " =" + ( m - r_j - _umax ) );
+ System.out.println( " min_m=" + min_m );
+ if ( ( m - r_j - _umax ) > min_m ) {
+ System.out.println(">>>>>>>>>>>>>>>>>>>>>>" + m );
+ continue J;
}
}
if ( _verbose ) {
System.out.println();
- for( final Entry<Integer, SortedSet<Integer>> entry : _s.getSentrySet( m_j ) ) {
+ for( final Entry<Integer, Set<Integer>> entry : _s.getSentrySet( m_j ) ) {
for( final int sorted_i : entry.getValue() ) {
System.out.print( sorted_i );
System.out.print( "->" );
import java.text.DecimalFormat;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
-import java.util.TreeSet;
import org.forester.evoinference.matrix.distance.BasicSymmetricalDistanceMatrix;
public final static int FACTOR = 1000000;
private final static boolean DEBUG = true;
- private final List<SortedMap<Integer, SortedSet<Integer>>> _data;
+ private final List<SortedMap<Integer, Set<Integer>>> _data;
public S() {
- _data = new ArrayList<SortedMap<Integer, SortedSet<Integer>>>();
+ _data = new ArrayList<SortedMap<Integer, Set<Integer>>>();
}
final public void addPairing( final double key, final int value, final int j ) {
addPairing( key, value, getS( j ) );
}
- final public SortedMap<Integer, SortedSet<Integer>> getS( final int j ) {
+ final public SortedMap<Integer, Set<Integer>> getS( final int j ) {
return _data.get( j );
}
- final public SortedSet<Integer> getValues( final int key, final int j ) {
+ final public Set<Integer> getValues( final int key, final int j ) {
return getS( j ).get( key );
}
final public void initialize( final BasicSymmetricalDistanceMatrix d ) {
for( int j = 0; j < d.getSize(); ++j ) {
- final TreeMap<Integer, SortedSet<Integer>> map = new TreeMap<Integer, SortedSet<Integer>>();
+ final TreeMap<Integer, Set<Integer>> map = new TreeMap<Integer, Set<Integer>>();
_data.add( map );
for( int i = 0; i < j; ++i ) {
addPairing( ( int ) ( FACTOR * d.getValues()[ i ][ j ] ), i, map );
final public void initialize( final int size ) {
for( int j = 0; j < size; ++j ) {
- final TreeMap<Integer, SortedSet<Integer>> map = new TreeMap<Integer, SortedSet<Integer>>();
+ final TreeMap<Integer, Set<Integer>> map = new TreeMap<Integer, Set<Integer>>();
_data.add( map );
}
}
}
final public void removePairing( final int key, final int value, final int j ) {
- final SortedMap<Integer, SortedSet<Integer>> m = _data.get( j );
- final SortedSet<Integer> x = m.get( key );
+ final SortedMap<Integer, Set<Integer>> m = _data.get( j );
+ final Set<Integer> x = m.get( key );
if ( DEBUG ) {
if ( x == null ) {
System.out.println();
// Slow, only for testing
@SuppressWarnings( "unchecked")
- final public SortedSet<Integer>[] toArray( final int j ) {
- return _data.get( j ).values().toArray( new SortedSet[ _data.get( j ).size() ] );
+ final public Set<Integer>[] toArray( final int j ) {
+ return _data.get( j ).values().toArray( new Set[ _data.get( j ).size() ] );
}
@Override
for( int j = 0; j < size(); ++j ) {
sb.append( j );
sb.append( ": " );
- for( final Entry<Integer, SortedSet<Integer>> entry : getSentrySet( j ) ) {
+ for( final Entry<Integer, Set<Integer>> entry : getSentrySet( j ) ) {
final double key = entry.getKey();
- final SortedSet<Integer> values = entry.getValue();
+ final Set<Integer> values = entry.getValue();
sb.append( df.format( key / FACTOR ) + "->" );
boolean first = true;
for( final int v : values ) {
return sb.toString();
}
- final Set<Entry<Integer, SortedSet<Integer>>> getSentrySet( final int j ) {
+ final Set<Entry<Integer, Set<Integer>>> getSentrySet( final int j ) {
return getS( j ).entrySet();
}
- final private static void addPairing( final int key, final int value, final SortedMap<Integer, SortedSet<Integer>> m ) {
+ final private static void addPairing( final int key, final int value, final SortedMap<Integer, Set<Integer>> m ) {
if ( !m.containsKey( key ) ) {
- final TreeSet<Integer> x = new TreeSet<Integer>();
+ final HashSet<Integer> x = new HashSet<Integer>();
x.add( value );
m.put( key, x );
}