---
name: "mlpack_neighbor_FurthestNeighborSort"
section: "3"
platform: "linux"
package: "mlpack-doc"
version: "1.0.10-1"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/mlpack_neighbor_FurthestNeighborSort"
---

# mlpack\_neighbor\_FurthestNeighborSort(3)

This class implements the necessary methods for the SortPolicy template parameter of the NeighborSearch class.

## NAME

mlpack::neighbor::FurthestNeighborSort -

This class implements the necessary methods for the SortPolicy template parameter of the **NeighborSearch** class.

## SYNOPSIS

### Static Public Member Functions

static double **BestDistance** ()\
 *Return what should represent the best possible distance with this particular sort policy.*  template\<typename TreeType \> static double **BestNodeToNodeDistance** (const TreeType \*queryNode, const TreeType \*referenceNode)\
 *Return the best possible distance between two nodes.*  template\<typename TreeType \> static double **BestNodeToNodeDistance** (const TreeType \*queryNode, const TreeType \*referenceNode, const double centerToCenterDistance)\
 *Return the best possible distance between two nodes, given that the distance between the centers of the two nodes has already been calculated.*  template\<typename TreeType \> static double **BestNodeToNodeDistance** (const TreeType \*queryNode, const TreeType \*referenceNode, const TreeType \*referenceChildNode, const double centerToCenterDistance)\
 *Return the best possible distance between the query node and the reference child node given the base case distance between the query node and the reference node.*  template\<typename VecType , typename TreeType \> static double **BestPointToNodeDistance** (const VecType &queryPoint, const TreeType \*referenceNode)\
 *Return the best possible distance between a node and a point.*  template\<typename VecType , typename TreeType \> static double **BestPointToNodeDistance** (const VecType &queryPoint, const TreeType \*referenceNode, const double pointToCenterDistance)\
 *Return the best possible distance between a point and a node, given that the distance between the point and the center of the node has already been calculated.*  static double **CombineBest** (const double a, const double b)\
 *Return the best combination of the two distances.*  static double **CombineWorst** (const double a, const double b)\
 *Return the worst combination of the two distances.*  static bool **IsBetter** (const double value, const double ref)\
 *Return whether or not value is 'better' than ref.*  static size\_t **SortDistance** (const arma::vec &list, const arma::Col\< size\_t \> &indices, double newDistance)\
 *Return the index in the vector where the new distance should be inserted, or size\_t() - 1 if it should not be inserted (i.e.*  static double **WorstDistance** ()\
 *Return what should represent the worst possible distance with this particular sort policy.*

## Detailed Description

This class implements the necessary methods for the SortPolicy template parameter of the **NeighborSearch** class.

The sorting policy here is that the minimum distance is the best (so, when used with **NeighborSearch**, the output is furthest neighbors).

Definition at line 37 of file furthest\_neighbor\_sort.hpp.

## Member Function Documentation

### static double mlpack::neighbor::FurthestNeighborSort::BestDistance ()` [inline]`, ` [static]`

Return what should represent the best possible distance with this particular sort policy. In our case, this should be the maximum possible distance, DBL\_MAX.

**Returns:**

DBL\_MAX

Definition at line 146 of file furthest\_neighbor\_sort.hpp.

### template\<typename TreeType \> static double mlpack::neighbor::FurthestNeighborSort::BestNodeToNodeDistance (const TreeType \*queryNode, const TreeType \*referenceNode)` [static]`

Return the best possible distance between two nodes. In our case, this is the maximum distance between the two tree nodes using the given distance function.

### template\<typename TreeType \> static double mlpack::neighbor::FurthestNeighborSort::BestNodeToNodeDistance (const TreeType \*queryNode, const TreeType \*referenceNode, const doublecenterToCenterDistance)` [static]`

Return the best possible distance between two nodes, given that the distance between the centers of the two nodes has already been calculated. This is used in conjunction with trees that have self-children (like cover trees).

### template\<typename TreeType \> static double mlpack::neighbor::FurthestNeighborSort::BestNodeToNodeDistance (const TreeType \*queryNode, const TreeType \*referenceNode, const TreeType \*referenceChildNode, const doublecenterToCenterDistance)` [static]`

Return the best possible distance between the query node and the reference child node given the base case distance between the query node and the reference node. TreeType::ParentDistance() must be implemented to use this.

**Parameters:**

*queryNode* Query node. \
 *referenceNode* Reference node. \
 *referenceChildNode* Child of reference node which is being inspected. \
 *centerToCenterDistance* Distance between centers of query node and reference node.

### template\<typename VecType , typename TreeType \> static double mlpack::neighbor::FurthestNeighborSort::BestPointToNodeDistance (const VecType &queryPoint, const TreeType \*referenceNode)` [static]`

Return the best possible distance between a node and a point. In our case, this is the maximum distance between the tree node and the point using the given distance function.

### template\<typename VecType , typename TreeType \> static double mlpack::neighbor::FurthestNeighborSort::BestPointToNodeDistance (const VecType &queryPoint, const TreeType \*referenceNode, const doublepointToCenterDistance)` [static]`

Return the best possible distance between a point and a node, given that the distance between the point and the center of the node has already been calculated. This is used in conjunction with trees that have self-children (like cover trees).

### static double mlpack::neighbor::FurthestNeighborSort::CombineBest (const doublea, const doubleb)` [inline]`, ` [static]`

Return the best combination of the two distances.

Definition at line 151 of file furthest\_neighbor\_sort.hpp.

### static double mlpack::neighbor::FurthestNeighborSort::CombineWorst (const doublea, const doubleb)` [inline]`, ` [static]`

Return the worst combination of the two distances.

Definition at line 161 of file furthest\_neighbor\_sort.hpp.

### static bool mlpack::neighbor::FurthestNeighborSort::IsBetter (const doublevalue, const doubleref)` [inline]`, ` [static]`

Return whether or not value is 'better' than ref. In this case, that means that the value is greater than the reference.

**Parameters:**

*value* Value to compare \
 *ref* Value to compare with

**Returns:**

bool indicating whether or not (value \> ref).

Definition at line 67 of file furthest\_neighbor\_sort.hpp.

### static size\_t mlpack::neighbor::FurthestNeighborSort::SortDistance (const arma::vec &list, const arma::Col\< size\_t \> &indices, doublenewDistance)` [static]`

Return the index in the vector where the new distance should be inserted, or size\_t() - 1 if it should not be inserted (i.e. if it is not any better than any of the existing points in the list). The list should be sorted such that the best point is the first in the list. The actual insertion is not performed.

**Parameters:**

*list* Vector of existing distance points, sorted such that the best point is the first in the list. \
 *new\_distance* Distance to try to insert.

**Returns:**

size\_t containing the position to insert into, or (size\_t() - 1) if the new distance should not be inserted.

### static double mlpack::neighbor::FurthestNeighborSort::WorstDistance ()` [inline]`, ` [static]`

Return what should represent the worst possible distance with this particular sort policy. In our case, this should be the minimum possible distance, 0.

**Returns:**

0

Definition at line 137 of file furthest\_neighbor\_sort.hpp.

## Author

Generated automatically by Doxygen for MLPACK from the source code.
