bk_tree 0.1.1 copy "bk_tree: ^0.1.1" to clipboard
bk_tree: ^0.1.1 copied to clipboard

A Dart BK-Tree implementation for efficient nearest neighbor searches using Hamming distance, optimized for bulk file hash processing and duplicate detection.

bk_tree #

Pub Version Pub Points License GitHub Workflow Status

A Dart BK-Tree implementation for efficient nearest neighbor searches using Hamming distance, optimized for bulk file hash processing and duplicate detection.

Compatibility: Dart ^3.6.0


๐Ÿš€ Getting Started #

Installation #

Method 1 (Recommended) With Dart:

dart pub add bk_tree
copied to clipboard

With Flutter:

flutter pub add bk_tree
copied to clipboard

Method 2 Add to pubspec.yaml:

dependencies:
  bk_tree: ^0.1.1
copied to clipboard

Then run:

dart pub get
copied to clipboard

Basic Usage #

import "package:bk_tree/bk_tree.dart";

void main() {
  final tree = BKTree(
    yourHashMap,
    yourDistanceFunction,
  );
  final results = tree.search(
    queryHash: yourQueryHash,
    tolerance: n, // Your allowed n-bit difference
  );
}
copied to clipboard

๐Ÿ“ฆ Features #

  • Core Feature 1: Return a BK-Tree of a folder (using hamming distance)
final imageHashes = {
  "cat.jpg": "d3b07384d113edec",
  "dog.jpg": "c157a79031e1c40f",
  "cat_copy.jpg": "d3b07384d113edef", // Duplicate
  "landscape.png": "6f4b726212b23f0a",
};

// Create BK-Tree with Hamming distance
final tree = BKTree(
  imageHashes,
  hammingDistance, // Need from another place
);

// Search for duplicates of cat.jpg
final results = tree.search(
  queryHash: imageHashes["cat.jpg"]!,
  tolerance: 2, // Here allow 2-bit difference
);

print("Duplicate findings:");
for (var match in results) {
  match.forEach((file, distance) {
      print("- Target: cat.jpg. Find match $file (distance: $distance)");
  });
}
copied to clipboard

Output:

- Target: cat.jpg. Find match cat.jpg (distance: 0)
- Target: cat.jpg. Find match cat_copy.jpg (distance: 2)
copied to clipboard

๐Ÿงช Testing #

# Run tests with coverage
dart test
copied to clipboard

๐Ÿค Contributing #

Workflow #

  1. Fork repository
  2. Create feature branch:
    git checkout -b feat/your-feature
    
    copied to clipboard
  3. Follow Conventional Commits:
    git commit -m "feat: add new validation method"
    
    copied to clipboard

Code Style #

Follow the Effective Dart and analysis_options.yaml


๐Ÿ“š Documentation #


๐Ÿ“œ License #

BSD 3-Clause "New" or "Revised" License ยฉ 2025 RequieMa

Full text at LICENSE


๐Ÿšง Maintenance Status #

Basic functionalities are done. (Current version is to support author's other packages)

More General Version is under development.

Please report issues via GitHub Issues

2
likes
160
points
179
downloads

Publisher

unverified uploader

Weekly Downloads

2024.09.21 - 2025.04.05

A Dart BK-Tree implementation for efficient nearest neighbor searches using Hamming distance, optimized for bulk file hash processing and duplicate detection.

Repository (GitHub)
View/report issues

Topics

#data-structures #dart

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

logging, meta, path

More

Packages that depend on bk_tree