STANN

STANN‎ > ‎User Guide‎ > ‎

SFCNN_KNNG Specs

To Initialize

sfcnn_knng is a specialized version of the sfcnn algorithm
designed to quickly generate K-nearest neighbor graphs.
If compiled using openmp, it will use multiple processors
to compute the solution.  To include it in a program,
use sfcnn_knng.hpp

sfcnn_knng< MyPointType,
                        Dimension,
                        CoordType >
                NN(&FirstDataPoint, Size, k, ThreadCount);

  • MyPointType
    • This can be any user defined point type, as long as the
      coordinates can be referenced by the bracket operator.
      For example, vector<double> or float[], are both valid.
  • Dimension  
    • This is the dimension of the points in the data set.
  • CoordType
    • This is the type of coordinate the points use.
      Currently supported types are:
      (unsigned) short, int, long
      short, int, long
      float, double, long double
    • IMPORTANT! Searches on integer types operate
      about 3x faster than floating point types.  If you
      can use them, it is recommended.
  • FirstDataPoint
    • A pointer to the first point in the input data set
  • Size
    • The size of the input data set
  • k
    • The number of nearest neighbors to return. 
      Ie. k=5 will return the 5 nearest points to Q in
      the data set
  • ThreadCount
    • This is an optional parameter whose default
      value is 1. If compiled using openmp, this will
      set the number of processors to use during
      construction.

To Make a Query

Note: All calculation for the k nearest neighbor graph is
           done at initialization.

NN[i][j]     This returns the index of the jth nearest
                 neighbor to the ith data point.  The indexes
                 are all relative to the first data point
                 given at initialization.  If the data points
                 have moved, the answer will be incorrect.