Click or drag to resize
ClosestPair Class

The ClosestPair data type computes a closest pair of points in a set of N points in the plane and provides accessor methods for getting the closest pair of points and the distance between them. The distance between two points is their Euclidean distance.

This implementation uses a divide-and-conquer algorithm. It runs in O(N log N) time in the worst case and uses O(N) extra space. See also .

Inheritance Hierarchy
SystemObject
  Algs4NetClosestPair

Namespace: Algs4Net
Assembly: Algs4Net (in Algs4Net.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class ClosestPair

The ClosestPair type exposes the following members.

Constructors
  NameDescription
Public methodClosestPair
Computes the closest pair of points in the specified array of points.
Top
Properties
  NameDescription
Public propertyEither
Returns one of the points in the closest pair of points.
Public propertyOther
Returns the other point in the closest pair of points.
Top
Methods
  NameDescription
Public methodDistance
Returns the Eucliden distance between the closest pair of points.
Public methodStatic memberMainTest
Demo test the ClosestPair data type. Reads in an integer N and N points (specified by their X- and Y-coordinates) from standard input; computes a closest pair of points; and prints the pair to standard output.
Top
Remarks

For additional documentation, see Section 9.9 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

This class is a C# port from the original Java class ClosestPair implementation by the respective authors.

See Also