public OutlierResult run(Relation<V> relation){
  final int dimensionality=RelationUtil.dimensionality(relation);
  final int size=relation.size();
  ArrayList<ArrayList<DBIDs>> ranges=buildRanges(relation);
  ArrayList<ArrayList<IntIntPair>> Rk;
{
    Rk=new ArrayList<>();
    ArrayList<IntIntPair> q=new ArrayList<>();
    for (int i=0; i < dimensionality; i++) {
      for (int j=0; j < phi; j++) {
        IntIntPair s=new IntIntPair(i,j);
        q.add(s);
        ArrayList<IntIntPair> v=new ArrayList<>();
        v.add(s);
        Rk.add(v);
      }
    }
    for (int i=2; i <= k; i++) {
      ArrayList<ArrayList<IntIntPair>> Rnew=new ArrayList<>();
      for (int j=0; j < Rk.size(); j++) {
        ArrayList<IntIntPair> c=Rk.get(j);
        for (        IntIntPair pair : q) {
          boolean invalid=false;
          for (int t=0; t < c.size(); t++) {
            if (c.get(t).first == pair.first) {
              invalid=true;
              break;
            }
          }
          if (!invalid) {
            ArrayList<IntIntPair> neu=new ArrayList<>(c);
            neu.add(pair);
            Rnew.add(neu);
          }
        }
      }
      Rk=Rnew;
    }
  }
  WritableDoubleDataStore sparsity=DataStoreUtil.makeDoubleStorage(relation.getDBIDs(),DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_STATIC);
  for (  ArrayList<IntIntPair> sub : Rk) {
    DBIDs ids=computeSubspace(sub,ranges);
    final double sparsityC=sparsity(ids.size(),size,k,phi);
    if (sparsityC < 0) {
      for (DBIDIter iter=ids.iter(); iter.valid(); iter.advance()) {
        double prev=sparsity.doubleValue(iter);
        if (Double.isNaN(prev) || sparsityC < prev) {
          sparsity.putDouble(iter,sparsityC);
        }
      }
    }
  }
  DoubleMinMax minmax=new DoubleMinMax();
  for (DBIDIter iditer=relation.iterDBIDs(); iditer.valid(); iditer.advance()) {
    double val=sparsity.doubleValue(iditer);
    if (Double.isNaN(val)) {
      sparsity.putDouble(iditer,0.0);
      val=0.0;
    }
    minmax.put(val);
  }
  DoubleRelation scoreResult=new MaterializedDoubleRelation("AggarwalYuNaive","aggarwal-yu-outlier",sparsity,relation.getDBIDs());
  OutlierScoreMeta meta=new InvertedOutlierScoreMeta(minmax.getMin(),minmax.getMax(),Double.NEGATIVE_INFINITY,0.0);
  return new OutlierResult(meta,scoreResult);
}

public OutlierResult run ( Relation < V > relation ) { final int dimensionality = RelationUtil . dimensionality ( relation ) ; final int size = relation . size ( ) ; ArrayList < ArrayList < DBIDs > > ranges = buildRanges ( relation ) ; ArrayList < ArrayList < IntIntPair > > Rk ; { Rk = new ArrayList < > ( ) ; ArrayList < IntIntPair > q = new ArrayList < > ( ) ; for ( int i = 0 ; i < dimensionality ; i ++ ) { for ( int j = 0 ; j < phi ; j ++ ) { IntIntPair s = new IntIntPair ( i , j ) ; q . add ( s ) ; ArrayList < IntIntPair > v = new ArrayList < > ( ) ; v . add ( s ) ; Rk . add ( v ) ; } } for ( int i = 2 ; i <= k ; i ++ ) { ArrayList < ArrayList < IntIntPair > > Rnew = new ArrayList < > ( ) ; for ( int j = 0 ; j < Rk . size ( ) ; j ++ ) { ArrayList < IntIntPair > c = Rk . get ( j ) ; for ( IntIntPair pair : q ) { boolean invalid = false ; for ( int t = 0 ; t < c . size ( ) ; t ++ ) { if ( c . get ( t ) . first == pair . first ) { invalid = true ; break ; } } if ( ! invalid ) { ArrayList < IntIntPair > neu = new ArrayList < > ( c ) ; neu . add ( pair ) ; Rnew . add ( neu ) ; } } } Rk = Rnew ; } } WritableDoubleDataStore sparsity = DataStoreUtil . makeDoubleStorage ( relation . getDBIDs ( ) , DataStoreFactory . HINT_HOT | DataStoreFactory . HINT_STATIC ) ; for ( ArrayList < IntIntPair > sub : Rk ) { DBIDs ids = computeSubspace ( sub , ranges ) ; final double sparsityC = sparsity ( ids . size ( ) , size , k , phi ) ; if ( sparsityC < 0 ) { for ( DBIDIter iter = ids . iter ( ) ; iter . valid ( ) ; iter . advance ( ) ) { double prev = sparsity . doubleValue ( iter ) ; if ( Double . isNaN ( prev ) || sparsityC < prev ) { sparsity . putDouble ( iter , sparsityC ) ; } } } } DoubleMinMax minmax = new DoubleMinMax ( ) ; for ( DBIDIter iditer = relation . iterDBIDs ( ) ; iditer . valid ( ) ; iditer . advance ( ) ) { double val = sparsity . doubleValue ( iditer ) ; if ( Double . isNaN ( val ) ) { sparsity . putDouble ( iditer , 0.0 ) ; val = 0.0 ; } minmax . put ( val ) ; } DoubleRelation scoreResult = new MaterializedDoubleRelation ( "AggarwalYuNaive" , "aggarwal-yu-outlier" , sparsity , relation . getDBIDs ( ) ) ; OutlierScoreMeta meta = new InvertedOutlierScoreMeta ( minmax . getMin ( ) , minmax . getMax ( ) , Double . NEGATIVE_INFINITY , 0.0 ) ; return new OutlierResult ( meta , scoreResult ) ; }
run the algorithm on the given relation .
