The KGraph index.
More...
#include <kgraph.h>
|
enum | { FORMAT_DEFAULT = 0,
FORMAT_NO_DIST = 1
} |
|
|
virtual void | load (char const *path)=0 |
| Load index from file. More...
|
|
virtual void | save (char const *path, int format=FORMAT_DEFAULT) const =0 |
| Save index to file. More...
|
|
virtual void | build (IndexOracle const &oracle, IndexParams const ¶ms, IndexInfo *info=0)=0 |
| Build the index.
|
|
virtual void | prune (IndexOracle const &oracle, unsigned level)=0 |
| Prune the index. More...
|
|
unsigned | search (SearchOracle const &oracle, SearchParams const ¶ms, unsigned *ids, SearchInfo *info=0) const |
| Online k-NN search. More...
|
|
virtual unsigned | search (SearchOracle const &oracle, SearchParams const ¶ms, unsigned *ids, float *dists, SearchInfo *info) const =0 |
| Online k-NN search. More...
|
|
virtual void | get_nn (unsigned id, unsigned *nns, unsigned *M, unsigned *L) const |
| Get offline computed k-NNs of a given object. More...
|
|
virtual void | get_nn (unsigned id, unsigned *nns, float *dists, unsigned *M, unsigned *L) const =0 |
| Get offline computed k-NNs of a given object. More...
|
|
virtual void | reverse (int)=0 |
|
The KGraph index.
This is an abstract base class. Use KGraph::create to create an instance.
virtual void kgraph::KGraph::get_nn |
( |
unsigned |
id, |
|
|
unsigned * |
nns, |
|
|
unsigned * |
M, |
|
|
unsigned * |
L |
|
) |
| const |
|
inlinevirtual |
Get offline computed k-NNs of a given object.
See the full version of get_nn.
virtual void kgraph::KGraph::get_nn |
( |
unsigned |
id, |
|
|
unsigned * |
nns, |
|
|
float * |
dists, |
|
|
unsigned * |
M, |
|
|
unsigned * |
L |
|
) |
| const |
|
pure virtual |
Get offline computed k-NNs of a given object.
The user must provide space to save IndexParams::L values. The actually returned L could be smaller than IndexParams::L, and M <= L is the number of neighbors KGraph thinks could be most useful for online search, and is usually < L. If the index has been pruned, the returned L could be smaller than IndexParams::L used to construct the index.
id Object ID whose neighbor information are returned. nns Neighbor IDs, must have space to save IndexParams::L values. dists Distance values, must have space to save IndexParams::L values. M Useful number of neighbors, output only. L Actually returned number of neighbors, output only.
virtual void kgraph::KGraph::load |
( |
char const * |
path | ) |
|
|
pure virtual |
Load index from file.
- Parameters
-
path | Path to the index file. |
virtual void kgraph::KGraph::prune |
( |
IndexOracle const & |
oracle, |
|
|
unsigned |
level |
|
) |
| |
|
pure virtual |
Prune the index.
Pruning makes the index smaller to save memory, and makes online search on the pruned index faster. (The cost parameters of online search must be enlarged so accuracy is not reduced.)
Currently only two pruning levels are supported:
- PRUNE_LEVEL_1 = 1: Only reduces index size, fast.
- PRUNE_LEVEL_2 = 2: For improve online search speed, slow.
No pruning is done if level = 0.
virtual void kgraph::KGraph::save |
( |
char const * |
path, |
|
|
int |
format = FORMAT_DEFAULT |
|
) |
| const |
|
pure virtual |
Save index to file.
- Parameters
-
path | Path to the index file. |
Online k-NN search.
Search results are guaranteed to be ranked in ascending order of distance.
- Parameters
-
ids | Pointer to the memory where neighbor IDs are stored, must have space to save params.K ids. |
Online k-NN search.
Search results are guaranteed to be ranked in ascending order of distance.
- Parameters
-
ids | Pointer to the memory where neighbor IDs are stored, must have space to save params.K values. |
dists | Pointer to the memory where distances are stored, must have space to save params.K values. |
The documentation for this class was generated from the following file: