private static MotifRecord ADM ( double [ ] series , ArrayList < Integer > neighborhood , int motifSize , double range , double znormThreshold ) throws Exception { MotifRecord res = new MotifRecord ( - 1 , new ArrayList < Integer > ( ) ) ; ArrayList < BitSet > admDistances = new ArrayList < BitSet > ( neighborhood . size ( ) ) ; for ( int i = 0 ; i < neighborhood . size ( ) ; i ++ ) { admDistances . add ( new BitSet ( i ) ) ; } for ( int i = 0 ; i < neighborhood . size ( ) ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { // diagonal wouldn't count anyway boolean isMatch = isNonTrivialMatch ( series , neighborhood . get ( i ) , neighborhood . get ( j ) , motifSize , range , znormThreshold ) ; if ( isMatch ) { admDistances . get ( i ) . set ( j ) ; admDistances . get ( j ) . set ( i ) ; } } } int maxCount = 0 ; for ( int i = 0 ; i < neighborhood . size ( ) ; i ++ ) { int tmpCounter = 0 ; for ( int j = 0 ; j < neighborhood . size ( ) ; j ++ ) { if ( admDistances . get ( i ) . get ( j ) ) { tmpCounter ++ ; } } if ( tmpCounter > maxCount ) { maxCount = tmpCounter ; ArrayList < Integer > occurrences = new ArrayList <> ( ) ; for ( int j = 0 ; j < neighborhood . size ( ) ; j ++ ) { if ( admDistances . get ( i ) . get ( j ) ) { occurrences . add ( neighborhood . get ( j ) ) ; } } res = new MotifRecord ( neighborhood . get ( i ) , occurrences ) ; } } return res ; }
This is not a real ADM implementation .