private DTWPair[] getPairsFromList(ArrayList pairList, int size) { DTWPair[] pairs = new DTWPair[size]; for (int i = 0; i < size; i++) { pairs[i] = getPairFromList(pairList); } return(pairs); }
private DTWPair getPairFromList(ArrayList pairList) { Hashtable pairHash = new Hashtable(); for (int i = 0; i < pairList.Count; i++) { DTWPair pair = (DTWPair)pairList[i]; if (pairHash.Contains(pair.i0)) { DTWPair temp = (DTWPair)pairHash[pair.i0]; if (pair.dtw < temp.dtw) { temp.i1 = pair.i1; temp.dtw = pair.dtw; } } else { pairHash[pair.i0] = pair.clone(); } } DTWPair res = null; double maxValue = 0.0; foreach (DictionaryEntry de in pairHash) { DTWPair pair = (DTWPair)de.Value; if (pair.dtw > maxValue) { maxValue = pair.dtw; res = pair.clone(); } } ArrayList samples = new ArrayList(); for (int i = 0; i < pairList.Count; i++) { DTWPair pair = (DTWPair)pairList[i]; if ((pair.i0 == res.i0) || (pair.i0 == res.i1) || (pair.i1 == res.i0) || (pair.i1 == res.i1)) { continue; } samples.Add(pair); } pairList.Clear(); for (int i = 0; i < samples.Count; i++) { pairList.Add(samples[i]); } return(res); }