HNSW-Sharp

Installation

HNSW-Sharp is distributed on NuGet as HNSW.Net.

dotnet add package HNSW.Net

Or, with the older PackageReference syntax in your .csproj:

app/MyApp.csproj
<ItemGroup>
  <PackageReference Include="HNSW.Net" Version="*" />
</ItemGroup>

Target frameworks

The package multi-targets modern .NET. Any .NET 6.0+ runtime works. SIMD distance functions need a runtime that exposes System.Numerics.Vector<T> — which all supported .NET versions do.

Target Status
.NET 8.0 / 9.0 First-class — full SIMD path.
.NET 6.0 / 7.0 Supported.
.NET Framework 4.7.2+ Supported through netstandard2.0. SIMD throughput is lower than on modern .NET.

What gets installed

A single managed assembly — HNSW.Net.dll — plus its MessagePack-CSharp dependency, used for serialising graphs.

No native binaries, no model files, no startup downloads. Everything HNSW-Sharp does runs inside your process.

Verify the install

A one-liner is enough to confirm the package resolved correctly:

using HNSW.Net;

var graph = new SmallWorld<float[], float>(
    CosineDistance.NonOptimized,
    DefaultRandomGenerator.Instance,
    new SmallWorldParameters());

Console.WriteLine($"Empty graph parameters: M={graph.Parameters.M}, EfSearch={graph.Parameters.EfSearch}");

If that compiles and prints M=10, EfSearch=50 you're ready for the Quick Start.

Referenced by

© 2026 HNSW-Sharp. All rights reserved.