• MARS Website
  • Core API
  • SmartOpenHamburg API
  • Model Components API
  • Common API
Show / Hide Table of Contents
  • Mars.Common
    • GeoHash
    • GeoHashDecoder
    • GeohashDecodeResult
    • GeoHashEncoder
    • GeoHashPrecision
    • Hyperrectangle
    • InputHashHelper
    • PositionHelper
  • Mars.Common.Collections
    • BinaryArrayHeap<T>
    • DoubleBits
    • FibonacciHeap<T, TKey>
    • FibonacciHeapDoubleKey<T>
    • FibonacciHeapNode<T, TKey>
    • FibonacciHeapNodeDoubleKey<T>
    • HeapNode
    • IntervalSize
    • K2DTree<T>
    • K2dTreeNode<T>
    • KdTree
    • KdTree<T>
    • KdTreeBase<TNode>
    • KdTreeNode
    • KdTreeNode<T>
    • KdTreeNodeBase<TNode>
    • KdTreeNodeCollection<TNode>
    • KdTreeNodeList<T>
    • Key
    • Node<T>
    • NodeBase<T>
    • NodeDataContainer<T>
    • NodeDistance<TNode>
    • QuadTree<T>
    • Root<T>
    • TreeDataContainer<T>
  • Mars.Common.Collections.CritBit
    • ICritBitTree<TValue>
  • Mars.Common.Collections.Graph
    • EdgeData
    • GraphData
    • GraphSerializer
    • ISpatialGraph
    • KeyContainer
    • NodeData
    • SpatialGraph
    • SpatialGraphHelper
  • Mars.Common.Collections.Graph.Algorithms
    • AStar
    • CompressedPathDatabase
    • ContractionSearch
    • DepthLimitedTraversal
  • Mars.Common.Collections.Graph.Helper
    • INodeFinder
    • KdTreeNodeFinder
    • RunLengthEncoder
  • Mars.Common.Collections.KNNGraph
    • DefaultRandomGenerator
    • DistanceUtils
    • EventSources
    • EventSources.GraphBuildEventSource
    • EventSources.GraphSearchEventSource
    • IProgressReporter
    • IProvideRandomValues
    • KnnGraph<TItem, TDistance>
    • KnnGraph<TItem, TDistance>.KnnSearchResult
    • KnnGraph<TItem, TDistance>.Parameters
    • Node
    • ReverseComparer<T>
    • ReverseComparerExtensions
    • SelectionKind
    • TravelingCosts<TItem, TDistance>
  • Mars.Common.Compat
    • FormatDecoderAttribute
    • FormatEncoderAttribute
    • FormatHandlerAttribute
    • IntegerAttribute
    • NegativeIntegerAttribute
    • NonnegativeIntegerAttribute
    • NonpositiveIntegerAttribute
    • PositiveIntegerAttribute
  • Mars.Common.Data
    • DomainDataImporter
  • Mars.Common.Data.Providers
    • AscDataProvider
    • GeoJsonFeatureCollectionConverter
    • GeoJsonFeatureConverter
    • GeoJsonHelper
    • GeometryDataProvider
    • GraphMlProvider
    • HttpDataProvider
    • IDataProvider<TInput>
    • JsonFileDataProvider
    • JsonTextDataProvider
    • XmlFileDataProvider
    • XmlTextDataProvider
  • Mars.Common.Exceptions
    • DimensionMismatchException
    • ParseException
  • Mars.Common.IO
    • ExtensionMethods
    • FileClientUtils
    • FileKeys
    • HttpClientUtils
    • ObjectSerialize
    • Serializer
    • SerializerCompression
    • SparseFormat
    • SparseReader
    • SparseWriter
  • Mars.Common.IO.Attributes
    • SerializationBinderAttribute
    • SurrogateSelectorAttribute
  • Mars.Common.IO.Console
    • ChildProgressBar
    • IProgressBar
    • ProgressBar
    • ProgressBarBase
    • ProgressBarHeight
    • ProgressBarOptions
    • ProgressBarSimple
  • Mars.Common.IO.Csv
    • CsvAnalyzer
    • CsvReader
    • CsvReader.RecordEnumerator
    • CsvWriter
    • MissingFieldAction
    • ParseErrorAction
    • ValueTrimmingOptions
  • Mars.Common.IO.Events
    • ParseErrorEventArgs
  • Mars.Common.IO.Exceptions
    • MalformedCsvException
    • MissingFieldCsvException
  • Mars.Common.IO.Mapped
    • Context
    • DefaultArrayFactory
    • Extensions
    • IArrayFactory
    • ISerializableToStream
    • MappedAccessor<T>
    • MemoryMap
    • MemoryMap.CreateAccessorFunc<T>
    • MemoryMap.ReadFromDelegate<T>
    • MemoryMap.WriteToDelegate<T>
    • MemoryMapDelegates
    • MemoryMapDelegates.CreateAccessorFunc<T>
    • MemoryMapStream
  • Mars.Common.IO.Mapped.Accessors
    • MappedAccessorByte
    • MappedAccessorDouble
    • MappedAccessorInt16
    • MappedAccessorInt32
    • MappedAccessorInt64
    • MappedAccessorSingle
    • MappedAccessorUInt16
    • MappedAccessorUInt32
    • MappedAccessorUInt64
    • MappedAccessorVariable<T>
  • Mars.Common.IO.Mapped.Arrays
    • Array<T>
    • ArrayBase<T>
    • ArrayProfile
    • MappedArray<TMapped, T>
    • MappedArray<TMapped, T>.MapFrom
    • MappedArray<TMapped, T>.MapTo
    • MemoryArray<T>
    • VariableArray<T>
  • Mars.Common.IO.Mapped.Collections
    • MemoryBackedDictionary<TKey, TValue>
    • MemoryBackedList<T>
  • Mars.Common.IO.Mapped.Indexes
    • Index<T>
  • Mars.Common.IO.Mapped.Streams
    • CappedStream
  • Mars.Common.Socket
    • ByteOrder
    • CloseEventArgs
    • CloseStatusCode
    • CompressionMethod
    • ErrorEventArgs
    • Ext
    • MessageEventArgs
    • WebSocket
    • WebSocketException
    • WebSocketState
  • Mars.Common.Socket.Server
    • IWebSocketSession
    • WebHeaderCollection
    • WebSocketBehavior
    • WebSocketContext
    • WebSocketServer
    • WebSocketServiceHost
    • WebSocketServiceManager
    • WebSocketSessionManager
  • Mars.Numerics
    • Classes
    • Combinatorics
    • Constants
    • Distance
    • Elementwise
    • Jagged
    • MathematicsException
    • MathHelper
    • Matrix
    • MatrixOrder
    • MatrixType
    • Norm
    • Sort
    • Sorting
    • Sparse
    • Sparse<T>
    • Tools
    • Vector
    • VectorHelper
    • VectorType
  • Mars.Numerics.Comparers
    • ArrayComparer<T>
    • ComparerDirection
    • CustomComparer<T>
    • ElementComparer
    • ElementComparer<T>
    • GeneralComparer
    • StableComparer<T>
  • Mars.Numerics.Distances
    • Angular
    • Chebyshev
    • Cosine
    • Dirac<T>
    • Euclidean
    • Hamming
    • Hamming<T>
    • Haversine
    • Jaccard
    • Jaccard<T>
    • Kulczynski
    • Levenshtein
    • Levenshtein<T>
    • Manhattan
    • Matching
    • Minkowski
    • SquareEuclidean
    • Vincenty
    • Vincenty.Ellipsoid
  • Mars.Numerics.Distances.Base
    • IDistance<T>
    • IDistance<TFirst, TSecond>
    • IMetric<T>
    • ISimilarity<T, TU>
    • ISimilarity<T>
  • Mars.Numerics.Exceptions
    • DimensionMismatchException
    • NonPositiveDefiniteMatrixException
    • SingularMatrixException
  • Mars.Numerics.Formats
    • DefaultMatrixFormatProvider
    • IMatrixFormatProvider
    • MatrixFormatProviderBase
    • MatrixFormatter
    • OctaveMatrixFormatProvider
  • Mars.Numerics.Ranges
    • ByteRange
    • DoubleRange
    • FloatRange
    • IntRange
    • IRange<T>
  • Mars.Numerics.Statistics
    • ConstValueDistribution<T>
    • Distribution<T>
    • FastGaussianDistributionD
    • FastGaussianDistributionF
    • IDistribution
    • UniformDiscreteDistribution
    • UniformDistributionD
    • UniformDistributionF
  • Mars.Numerics.Statistics.Base
    • BinarySearch
    • DistributionBase
    • ISampleableDistribution<TObservations>
    • IUnivariateDistribution
    • IUnivariateDistribution<TObservation>
    • UnivariateDiscreteDistribution

Class KdTreeBase<TNode>

Base class for K-dimensional trees.
Inheritance
System.Object
Mars.Common.Core.Collections.SimpleTree.BinaryTree<TNode>
KdTreeBase<TNode>
K2DTree<T>
KdTree
KdTree<T>
Implements
System.Collections.Generic.IEnumerable<TNode>
System.Collections.IEnumerable
Inherited Members
Mars.Common.Core.Collections.SimpleTree.BinaryTree<TNode>.Root
Mars.Common.Core.Collections.SimpleTree.BinaryTree<TNode>.GetEnumerator()
Mars.Common.Core.Collections.SimpleTree.BinaryTree<TNode>.System.Collections.IEnumerable.GetEnumerator()
Mars.Common.Core.Collections.SimpleTree.BinaryTree<TNode>.SerializeJson()
Mars.Common.Core.Collections.SimpleTree.BinaryTree<TNode>.Deserialize(System.String)
Mars.Common.Core.Collections.SimpleTree.BinaryTree<TNode>.Traverse(Mars.Common.Core.Collections.SimpleTree.BinaryTraversalMethod<TNode>)
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Mars.Common.Collections
Assembly: Mars.Common.dll
Syntax
[Serializable]
public abstract class KdTreeBase<TNode> : BinaryTree<TNode>, IEnumerable<TNode>, IEnumerable where TNode : KdTreeNodeBase<TNode>, IComparable<TNode>, new()
Type Parameters
Name Description
TNode The class type for the nodes of the tree.

Constructors

| Improve this Doc View Source

KdTreeBase(Int32, TNode, Int32, Int32)

Creates a new KdTree<T>.
Declaration
public KdTreeBase(int dimension, TNode root, int count, int leaves)
Parameters
Type Name Description
System.Int32 dimension The number of dimensions in the tree.
TNode root The Root node, if already existent.
System.Int32 count The number of elements in the Root node.
System.Int32 leaves The number of leaves linked through the Root node.
| Improve this Doc View Source

KdTreeBase(Int32, TNode)

Creates a new KdTree<T>.
Declaration
public KdTreeBase(int dimension, TNode root)
Parameters
Type Name Description
System.Int32 dimension The number of dimensions in the tree.
TNode root The Root node, if already existent.
| Improve this Doc View Source

KdTreeBase(Int32)

Creates a new KdTree<T>.
Declaration
public KdTreeBase(int dimensions)
Parameters
Type Name Description
System.Int32 dimensions The number of dimensions in the tree.

Properties

| Improve this Doc View Source

Count

Gets the number of elements contained in this tree. This is also the number of tree nodes.
Declaration
[JsonProperty("count")]
public int Count { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Dimensions

Gets the number of dimensions expected by the input points of this tree.
Declaration
[JsonProperty("dimensions")]
public int Dimensions { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Distance

Gets or set the distance function used to measure distances amongst points on this tree
Declaration
public IMetric<double[]> Distance { get; set; }
Property Value
Type Description
IMetric<System.Double[]>
| Improve this Doc View Source

Leaves

Gets the number of leaves contained in this tree. This can be used to calibrate approximate nearest searchers.
Declaration
[JsonProperty("leaves")]
public int Leaves { get; }
Property Value
Type Description
System.Int32

Methods

| Improve this Doc View Source

AddNode(Double[])

Inserts a value into the tree at the desired position.
Declaration
protected TNode AddNode(double[] position)
Parameters
Type Name Description
System.Double[] position A double-vector with the same number of elements as dimensions in the tree.
Returns
Type Description
TNode
| Improve this Doc View Source

ApproximateNearest(Double[], Double, out Double)

Retrieves a percentage of nearest points to a given point.
Declaration
public TNode ApproximateNearest(double[] position, double percentage, out double distance)
Parameters
Type Name Description
System.Double[] position The queried point.
System.Double percentage The maximum percentage of leaf nodes that can be visited before the search finishes with an approximate answer.
System.Double distance The distance between the query point and its nearest neighbor.
Returns
Type Description
TNode A list of neighbor points, ordered by distance.
| Improve this Doc View Source

ApproximateNearest(Double[], Double)

Retrieves a percentage of nearest points to a given point.
Declaration
public TNode ApproximateNearest(double[] position, double percentage)
Parameters
Type Name Description
System.Double[] position The queried point.
System.Double percentage The maximum percentage of leaf nodes that can be visited before the search finishes with an approximate answer.
Returns
Type Description
TNode A list of neighbor points, ordered by distance.
| Improve this Doc View Source

ApproximateNearest(Double[], Int32, Double)

Retrieves a fixed percentage of nearest points to a given point.
Declaration
public KdTreeNodeCollection<TNode> ApproximateNearest(double[] position, int neighbors, double percentage)
Parameters
Type Name Description
System.Double[] position The queried point.
System.Int32 neighbors The number of neighbors to retrieve.
System.Double percentage The maximum percentage of leaf nodes that can be visited before the search finishes with an approximate answer.
Returns
Type Description
KdTreeNodeCollection<TNode> A list of neighbor points, ordered by distance.
| Improve this Doc View Source

ApproximateNearest(Double[], Int32, Int32)

Retrieves a fixed number of nearest points to a given point.
Declaration
public KdTreeNodeCollection<TNode> ApproximateNearest(double[] position, int neighbors, int maxLeaves)
Parameters
Type Name Description
System.Double[] position The queried point.
System.Int32 neighbors The number of neighbors to retrieve.
System.Int32 maxLeaves The maximum number of leaf nodes that can be visited before the search finishes with an approximate answer.
Returns
Type Description
KdTreeNodeCollection<TNode> A list of neighbor points, ordered by distance.
| Improve this Doc View Source

ApproximateNearest(Double[], Int32)

Retrieves a fixed number of nearest points to a given point.
Declaration
public TNode ApproximateNearest(double[] position, int maxLeaves)
Parameters
Type Name Description
System.Double[] position The queried point.
System.Int32 maxLeaves The maximum number of leaf nodes that can be visited before the search finishes with an approximate answer.
Returns
Type Description
TNode A list of neighbor points, ordered by distance.
| Improve this Doc View Source

Clear()

Removes all nodes from this tree.
Declaration
public void Clear()
| Improve this Doc View Source

CopyTo(TNode[], Int32)

Copies the entire tree to a compatible one-dimensional System.Array, starting at the specified arrayIndex of the array .
Declaration
public void CopyTo(TNode[] array, int arrayIndex)
Parameters
Type Name Description
TNode[] array The one-dimensional System.Array that is the destination of the elements copied from tree. The System.Array must have zero-based indexing.
System.Int32 arrayIndex The zero-based index in array at which copying begins.
| Improve this Doc View Source

CreateRoot(Double[][], Boolean, out Int32)

Creates the Root node for a new KdTree<T> given a set of data points and their respective stored values.
Declaration
protected static TNode CreateRoot(double[][] points, bool inPlace, out int leaves)
Parameters
Type Name Description
System.Double[][] points The data points to be inserted in the tree.
System.Boolean inPlace Whether the given points vector can be ordered in place. Passing true will change the original order of the vector. If set to false, all operations will be performed on an extra copy of the vector.
System.Int32 leaves Return the number of leaves in the Root subtree.
Returns
Type Description
TNode The Root node for a new KdTree<T> contained the given points.
| Improve this Doc View Source

InsideRegion(Hyperrectangle)

Retrieves a list of all points inside a given region.
Declaration
public IList<TNode> InsideRegion(Hyperrectangle region)
Parameters
Type Name Description
Hyperrectangle region The region.
Returns
Type Description
System.Collections.Generic.IList<TNode> A list of all nodes contained in the region.
| Improve this Doc View Source

Nearest(Position, Double, Int32, Func<TNode, Boolean>)

Retrieves the nearest points to a given Position within a given radius.
Declaration
public ICollection<NodeDistance<TNode>> Nearest(Position position, double radius, int maximum, Func<TNode, bool> predicate = null)
Parameters
Type Name Description
Position position The queried Position.
System.Double radius The search radius.
System.Int32 maximum The maximum number of neighbors to retrieve.
System.Func<TNode, System.Boolean> predicate The predicate to filter out the nodes.
Returns
Type Description
System.Collections.Generic.ICollection<NodeDistance<TNode>> A list of neighbor points, ordered by distance.
| Improve this Doc View Source

Nearest(Double[], Double, Func<TNode, Boolean>)

Retrieves the nearest points to a given point within a given radius.
Declaration
public List<NodeDistance<TNode>> Nearest(double[] position, double radius, Func<TNode, bool> predicate = null)
Parameters
Type Name Description
System.Double[] position The queried point.
System.Double radius The search radius.
System.Func<TNode, System.Boolean> predicate The predicate to filter out the nodes.
Returns
Type Description
System.Collections.Generic.List<NodeDistance<TNode>> A list of neighbor points, ordered by distance.
| Improve this Doc View Source

Nearest(Double[], Double, Int32, Func<TNode, Boolean>)

Retrieves the nearest points to a given point within a given radius.
Declaration
public ICollection<NodeDistance<TNode>> Nearest(double[] position, double radius, int maximum, Func<TNode, bool> predicate = null)
Parameters
Type Name Description
System.Double[] position The queried point.
System.Double radius The search radius.
System.Int32 maximum The maximum number of neighbors to retrieve.
System.Func<TNode, System.Boolean> predicate The predicate to filter out the nodes.
Returns
Type Description
System.Collections.Generic.ICollection<NodeDistance<TNode>> A list of neighbor points, ordered by distance.
| Improve this Doc View Source

Nearest(Double[], out Double, Func<TNode, Boolean>)

Retrieves the nearest point to a given point.
Declaration
public TNode Nearest(double[] position, out double distance, Func<TNode, bool> predicate = null)
Parameters
Type Name Description
System.Double[] position The queried point.
System.Double distance The distance from the position to its nearest neighbor found in the tree.
System.Func<TNode, System.Boolean> predicate The predicate to filter out the nodes.
Returns
Type Description
TNode A list of neighbor points, ordered by distance.
| Improve this Doc View Source

Nearest(Double[], Int32, Func<TNode, Boolean>)

Retrieves a fixed number of nearest points to a given point.
Declaration
public KdTreeNodeCollection<TNode> Nearest(double[] position, int neighbors, Func<TNode, bool> predicate = null)
Parameters
Type Name Description
System.Double[] position The queried point.
System.Int32 neighbors The number of neighbors to retrieve.
System.Func<TNode, System.Boolean> predicate The predicate to filter out the nodes.
Returns
Type Description
KdTreeNodeCollection<TNode> A list of neighbor points, ordered by distance.
| Improve this Doc View Source

Nearest(Double[])

Retrieves the nearest point to a given point.
Declaration
public TNode Nearest(double[] position)
Parameters
Type Name Description
System.Double[] position The queried point.
Returns
Type Description
TNode A list of neighbor points, ordered by distance.
| Improve this Doc View Source

Nearest<T1>(Double[], Double, Int32, Func<TNode, T1, Boolean>, T1)

Base class for K-dimensional trees.
Declaration
public ICollection<NodeDistance<TNode>> Nearest<T1>(double[] position, double radius, int maximum, Func<TNode, T1, bool> predicate = null, T1 t1 = null)
Parameters
Type Name Description
System.Double[] position
System.Double radius
System.Int32 maximum
System.Func<TNode, T1, System.Boolean> predicate
T1 t1
Returns
Type Description
System.Collections.Generic.ICollection<NodeDistance<TNode>>
Type Parameters
Name Description
T1
| Improve this Doc View Source

Nearest<T1, T2>(Double[], Double, Int32, Func<TNode, T1, T2, Boolean>, T1, T2)

Base class for K-dimensional trees.
Declaration
public ICollection<NodeDistance<TNode>> Nearest<T1, T2>(double[] position, double radius, int maximum, Func<TNode, T1, T2, bool> predicate = null, T1 t1 = null, T2 t2 = null)
Parameters
Type Name Description
System.Double[] position
System.Double radius
System.Int32 maximum
System.Func<TNode, T1, T2, System.Boolean> predicate
T1 t1
T2 t2
Returns
Type Description
System.Collections.Generic.ICollection<NodeDistance<TNode>>
Type Parameters
Name Description
T1
T2
| Improve this Doc View Source

Nearest<T1, T2, T3>(Double[], Double, Int32, Func<TNode, T1, T2, T3, Boolean>, T1, T2, T3)

Base class for K-dimensional trees.
Declaration
public ICollection<NodeDistance<TNode>> Nearest<T1, T2, T3>(double[] position, double radius, int maximum, Func<TNode, T1, T2, T3, bool> predicate = null, T1 t1 = null, T2 t2 = null, T3 t3 = null)
Parameters
Type Name Description
System.Double[] position
System.Double radius
System.Int32 maximum
System.Func<TNode, T1, T2, T3, System.Boolean> predicate
T1 t1
T2 t2
T3 t3
Returns
Type Description
System.Collections.Generic.ICollection<NodeDistance<TNode>>
Type Parameters
Name Description
T1
T2
T3

Implements

System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable

Extension Methods

Serializer.Save<T>(T, out Byte[], SerializerCompression)
Serializer.Save<T>(T, Stream, SerializerCompression)
Serializer.Save<T>(T, BinaryFormatter, Stream, SerializerCompression)
Serializer.Save<T>(T, String, SerializerCompression)
Serializer.Save<T>(T, String)
Matrix.Concatenate<T>(T, T[])
Matrix.Replace<T>(T, Object, Object)
Combinatorics.Subsets<T>(IEnumerable<T>, Boolean)
Combinatorics.Subsets<T>(IEnumerable<T>, Int32, Boolean)
Matrix.SetEquals<T>(IEnumerable<T>, IEnumerable<T>)
DomainDataImporter.Import(IEnumerable<Object>, InputConfiguration)
DomainDataImporter.Import(Object, InputConfiguration)
ObjectSerialize.Serialize(Object)
Matrix.IsEqual(Object, Object, Decimal, Decimal)
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © MARS GROUP. HAW Hamburg