1. A method for identifying a set of nearest neighbors comprising: receiving a test object; for each of a set of dataset objects, computing a pairwise distance between the test object and the dataset object, the dataset objects and test object being represented by nodes of a graph, edges of the graph representing pairwise distances between respective pairs of the objects; with a processor, iteratively selecting one of the dataset objects to add to a set of nearest neighbors until the set of nearest neighbors includes a predefined number of nearest neighbors, the selected dataset object at each iteration being a dataset object which is not currently in the set of nearest neighbors for which there is no other dataset object not currently in the set of nearest neighbors which has a smaller pairwise distance to any of a subset of objects than the selected dataset object, the subset of objects consisting of the test object and the dataset objects currently in the set of nearest neighbors; and outputting at least one of: the set of nearest neighbors; and information based thereon.