HNSWIndex 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package HNSWIndex --version 1.0.2                
NuGet\Install-Package HNSWIndex -Version 1.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HNSWIndex" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HNSWIndex --version 1.0.2                
#r "nuget: HNSWIndex, 1.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install HNSWIndex as a Cake Addin
#addin nuget:?package=HNSWIndex&version=1.0.2

// Install HNSWIndex as a Cake Tool
#tool nuget:?package=HNSWIndex&version=1.0.2                

HNSWIndex

HNSWIndex is a .NET library for constructing approximate nearest-neighbor (ANN) indices based on the Hierarchical Navigable Small World (HNSW) graph. This data structure provides efficient similarity searches for large, high-dimensional datasets.

Key Features

  • High Performance: Implements the HNSW algorithm for fast approximate k-NN search.
  • Flexible Distance Metric: Pass any Func<TLabel, TLabel, TDistance> for custom distance calculation.
  • Flexible Heuristic: Pass heuristic function for nodes linking.
  • Concurrency Support: Thread safe graph building API
  • Configurable Parameters: Fine-tune the indexing performance and memory trade-offs with parameters

Installation

Install via NuGet:

dotnet add package HNSWIndex

Or inside your .csproj:

<PackageReference Include="HNSWIndex" Version="x.x.x" />

Getting Started

1. Optionally configure parameters

var parameters = new HNSWParameters
{ 
    RandomSeed = 123,
    DistributionRate = 1.0,
    MaxEdges = 16,
    CollectionSize = 1024,
    // ... other parameters
};

2. Create empty graph structure ()

var index = new HNSWIndex<float[], float>(Metrics.SquaredEuclideanMetric.Compute);

3. Build the graph

var vectors = RandomVectors();
foreach (var vector in vectors)
{
	index.Add(vector)
}

Or multi-threaded

var vectors = RandomVectors();
Parallel.For(0, vectors.Count, i => {
    index.Add(vectors[i]);
});

4. Query the structure

var k = 5;
var results = index.KnnQuery(queryPoint, k);
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.4 87 17 days ago
1.1.3 101 18 days ago
1.1.2 86 21 days ago
1.1.1 93 23 days ago
1.1.0 89 a month ago
1.0.2 88 a month ago
1.0.1 96 2 months ago
1.0.0 100 2 months ago