codeandcats / kdtree Goto Github PK
View Code? Open in Web Editor NEWA fast, generic, multi-dimensional Binary Search Tree written in C#
License: MIT License
A fast, generic, multi-dimensional Binary Search Tree written in C#
License: MIT License
I was surprized by lack of default DoubleMath
implementation. Maybe it should be added and registered by default, and maybe we need some another generic way to define instances for all the standard number types without duplicating the code too much.
I'm confused about split HyperRect.
Some articles point out that split HyperRect dimension should has max variance.
But you just choose X-aix at first and alerative at next depth.
Did it correct?
Currently the tree will not allow you to add multiple data points with the same coordinates.
Though, I don't think there's any technical requirement for not allowing duplicate coordinates.
Hi,
I have used https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.methodimploptions AggressiveInlining
and mark my generic math classes like your. Seems this makes in .NET Core to be zero cost.
At least this attribute makes that more likely. May be measure.
Thanks
The code of the Clear function is below, it need to add the line of code with Count = 0
public void Clear()
{
if (root != null)
RemoveChildNodes(root);
}
shouldn't the kdtree be creating nodes on median values of an axis ?
nodes should not get deeper than dimensions ?
KdTree seems to always be ignoring the new values if there's an old value stored with the same key. Here's an example:
using System;
using KdTree;
using KdTree.Math;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
var tree = new KdTree<float, int>(2, new FloatMath());
var coords = new[] { 0.0f, 0.0f };
tree.Add(coords, 100);
tree.Add(coords, 200);
var z = tree.FindValueAt(coords);
Console.Write(z); // => 100, but I'd expect 200
}
}
}
It would be better to either replace the existing value or throw an exception. I think that the library should never silently ignore the user value.
Maybe the problem will be solved as part of #4.
Saving a
let t1 = new KdTree<float, Alrm>(1, new DoubleMath());
t1.SaveToFile(@"D:\alarms\alarmIndex.bin")
Gives the following error with about 7M entries:
System.Runtime.Serialization.SerializationException: The internal array cannot expand to greater than Int32.MaxValue elements.
at System.Runtime.Serialization.ObjectIDGenerator.Rehash()
at System.Runtime.Serialization.ObjectIDGenerator.GetId(Object obj, Boolean& firstTime)
However this worked for both saving and loading:
let ser = MBrace.FsPickler.BinarySerializer()
ser.Serialize(IO.File.Create @"D:\alarms\alarmIndex.bin", t1)
let t2:KdTree<float, Alrm> = ser.Deserialize(IO.File.OpenRead @"D:\alarms\alarmIndex.bin")
Maybe you can switch to FsPickler internally for serialization
Hi,
I have a dataset of 7600 items and I make a query to get the 40 nearest members but one of the expected results is missing. Is there any known bug? If you have time to have a look I can provide the dataset.
Sebastian
KD-Trees supports many different kinds of queries. One such example is to search for all elements within a given range in multiple dimensions.
If you are interested in adding this kind of query to the library then I would be happy to work on an implementation.
One use-case for this is when making virtualization in 2D canvases which I'm working on here: KristofferStrube/Blazor.SVGEditor#15
Project uses a reverse date version scheme (year.month.date). This was a bad practice I had inherited from a company I worked at at the time.
The version scheme should be updated to Major.Minor.Patch so that it updates correctly in NPM.
I found that root
in KdTree
's declaration is private and leftChild
and rightChild
is internal in KdTreeNode
. It seems that there may be no way to traverse KdTree for now.
It would be very nice to provide some basic usage examples. While using the library (which is very good and solved my tasks) I was confused by multiple things:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.