using System; namespace ZeroLevel.HNSW { /// /// Type of heuristic to select best neighbours for a node. /// public enum NeighbourSelectionHeuristic { /// /// Marker for the Algorithm 3 (SELECT-NEIGHBORS-SIMPLE) from the article. Implemented in /// SelectSimple, /// /// Marker for the Algorithm 4 (SELECT-NEIGHBORS-HEURISTIC) from the article. Implemented in /// SelectHeuristic } public sealed class NSWOptions { /// /// Mox node connections on Layer /// public readonly int M; /// /// Max search buffer /// public readonly int EF; /// /// Max search buffer for inserting /// public readonly int EFConstruction; /// /// Distance function beetween vectors /// public readonly Func Distance; public readonly bool ExpandBestSelection; public readonly bool KeepPrunedConnections; public readonly NeighbourSelectionHeuristic SelectionHeuristic; public readonly int LayersCount; private NSWOptions(int layersCount, int m, int ef, int ef_construction, Func distance, bool expandBestSelection, bool keepPrunedConnections, NeighbourSelectionHeuristic selectionHeuristic) { LayersCount = layersCount; M = m; EF = ef; EFConstruction = ef_construction; Distance = distance; ExpandBestSelection = expandBestSelection; KeepPrunedConnections = keepPrunedConnections; SelectionHeuristic = selectionHeuristic; } public static NSWOptions Create(int layersCount, int M, int EF, int EF_construction, Func distance, bool expandBestSelection = false, bool keepPrunedConnections = false, NeighbourSelectionHeuristic selectionHeuristic = NeighbourSelectionHeuristic.SelectSimple) => new NSWOptions(layersCount, M, EF, EF_construction, distance, expandBestSelection, keepPrunedConnections, selectionHeuristic); } }