edu.stanford.math.plex4.metric.impl
public class ExplicitMetricSpace extends java.lang.Object implements AbstractSearchableMetricSpace<java.lang.Integer>
Constructor and Description |
---|
ExplicitMetricSpace(double[][] distanceMatrix)
This constructor initializes the class with the given distance matrix.
|
Modifier and Type | Method and Description |
---|---|
double |
distance(java.lang.Integer a,
java.lang.Integer b)
This function returns the distance between two points.
|
double |
distance(int i,
int j)
This function returns the distance between the object at index i and the
object at index j.
|
gnu.trove.TIntHashSet |
getClosedNeighborhood(java.lang.Integer queryPoint,
double epsilon)
This function returns the set of indices of points that are contained in the closed ball
of radius epsilon, centered at the specified query point.
|
gnu.trove.TIntHashSet |
getKNearestNeighbors(java.lang.Integer queryPoint,
int k)
This function returns the indices of the k points that are closest to the given query point.
|
int |
getNearestPointIndex(java.lang.Integer queryPoint)
This function returns the index of the point within the metric space nearest to
the given query point.
|
gnu.trove.TIntHashSet |
getOpenNeighborhood(java.lang.Integer queryPoint,
double epsilon)
This function returns the set of indices of points that are contained in the open ball
of radius epsilon, centered at the specified query point.
|
java.lang.Integer |
getPoint(int index)
This function returns the point at the specified index.
|
java.lang.Integer[] |
getPoints()
This function returns the set of points in the metric space as an array.
|
int |
size()
This function returns the number of points in the metric space.
|
public ExplicitMetricSpace(double[][] distanceMatrix)
distanceMatrix
- the distance matrix to initialize withAbstractSearchableMetricSpace
public double distance(int i, int j)
AbstractIntMetricSpace
distance
in interface AbstractIntMetricSpace
i
- the index of the first objectj
- the index of the second objectpublic int size()
AbstractIntMetricSpace
size
in interface AbstractIntMetricSpace
public gnu.trove.TIntHashSet getClosedNeighborhood(java.lang.Integer queryPoint, double epsilon)
AbstractSearchableMetricSpace
getClosedNeighborhood
in interface AbstractSearchableMetricSpace<java.lang.Integer>
queryPoint
- the center of the closed ballepsilon
- the radius of the closed ballpublic gnu.trove.TIntHashSet getKNearestNeighbors(java.lang.Integer queryPoint, int k)
AbstractSearchableMetricSpace
getKNearestNeighbors
in interface AbstractSearchableMetricSpace<java.lang.Integer>
queryPoint
- the reference pointk
- the number of nearest neighbors to getpublic int getNearestPointIndex(java.lang.Integer queryPoint)
AbstractSearchableMetricSpace
getNearestPointIndex
in interface AbstractSearchableMetricSpace<java.lang.Integer>
queryPoint
- the query pointpublic gnu.trove.TIntHashSet getOpenNeighborhood(java.lang.Integer queryPoint, double epsilon)
AbstractSearchableMetricSpace
getOpenNeighborhood
in interface AbstractSearchableMetricSpace<java.lang.Integer>
queryPoint
- the center of the open ballepsilon
- the radius of the open ballpublic java.lang.Integer getPoint(int index)
AbstractObjectMetricSpace
getPoint
in interface AbstractObjectMetricSpace<java.lang.Integer>
index
- the index of the point to retrievepublic java.lang.Integer[] getPoints()
AbstractObjectMetricSpace
getPoints
in interface AbstractObjectMetricSpace<java.lang.Integer>
public double distance(java.lang.Integer a, java.lang.Integer b)
AbstractObjectMetric
distance
in interface AbstractObjectMetric<java.lang.Integer>
a
- the first pointb
- the second point