MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / makeVPTree

Method makeVPTree

JSAT/src/jsat/linear/vectorcollection/VPTree.java:323–349  ·  view source on GitHub ↗
(List<Pair<Double, Integer>> S)

Source from the content-addressed store, hash-verified

321
322 //The probability match is used to store and sort by median distances.
323 private TreeNode makeVPTree(List<Pair<Double, Integer>> S)
324 {
325 if(S.isEmpty())
326 return null;
327 else if(S.size() <= maxLeafSize)
328 {
329 VPLeaf leaf = new VPLeaf(S);
330 return leaf;
331 }
332
333 int vpIndex = selectVantagePointIndex(S);
334 final VPNode node = new VPNode(S.get(vpIndex).getSecondItem());
335
336 //move VP to front, its self dist is zero and we dont want it used in computing bounds.
337 Collections.swap(S, 0, vpIndex);
338 int splitIndex = sortSplitSet(S.subList(1, S.size()), node)+1;//ofset by 1 b/c we sckipped the VP, which was moved to the front
339
340 /*
341 * Re use the list and let it get altered. We must compute the right side first.
342 * If we altered the left side, the median would move left, and the right side
343 * would get thrown off or require aditonal book keeping.
344 */
345 node.right = makeVPTree(S.subList(splitIndex+1, S.size()));
346 node.left = makeVPTree(S.subList(1, splitIndex+1));
347
348 return node;
349 }
350
351 private TreeNode makeVPTree(final List<Pair<Double, Integer>> S, final ExecutorService threadpool, final ModifiableCountDownLatch mcdl)
352 {

Callers 3

VPTreeMethod · 0.95
insertMethod · 0.95
runMethod · 0.95

Calls 8

sortSplitSetMethod · 0.95
countUpMethod · 0.80
submitMethod · 0.80
sizeMethod · 0.65
getSecondItemMethod · 0.45
getMethod · 0.45
swapMethod · 0.45

Tested by

no test coverage detected