/** * Prints out the contents of the neighborlist. */ public void printList() { if (isEmpty()) { System.out.println("Empty list"); } else { NeighborNode current = m_First; while (current != null) { System.out.println("Node: instance " + current.m_Instance + ", distance " + current.m_Distance); current = current.m_Next; } System.out.println(); } }
NeighborList list = new NeighborList(k); list.insertSorted(d, m_Root.p()); return list; NeighborList list = new NeighborList(k); d_node tmpnode; upper_bound = upper_k.peek().distance; tmpnode = zero_set.element(i); if (tmpnode.dist <= upper_bound) { list.insertSorted(tmpnode.dist, tmpnode.n.p()); if (list.currentLength() <= 0) { throw new Exception("Error: No neighbour found. This cannot happen");
NeighborList list = new NeighborList(k); list.insertSorted(d, m_Root.p()); return list; NeighborList list = new NeighborList(k); d_node tmpnode; upper_bound = upper_k.peek().distance; tmpnode = zero_set.element(i); if (tmpnode.dist <= upper_bound) { list.insertSorted(tmpnode.dist, tmpnode.n.p()); if (list.currentLength() <= 0) { throw new Exception("Error: No neighbour found. This cannot happen");
NeighborList temp = new NeighborList(k); d_node ele; for (int i = 0; i < zero_set.length; i++) { ele = zero_set.element(i); if (ele.dist <= upper_k.peek().distance) { temp.insertSorted(ele.dist, ele.n.p()); // temp.push(ele.n.p());
NeighborList temp = new NeighborList(k); d_node ele; for (int i = 0; i < zero_set.length; i++) { ele = zero_set.element(i); if (ele.dist <= upper_k.peek().distance) { temp.insertSorted(ele.dist, ele.n.p()); // temp.push(ele.n.p());
NeighborNode node = result.element(0).getFirst(); m_DistanceList = new double[result.element(0).currentLength()]; int i = 0; while (node != null) {
if (isEmpty()) { m_First = m_Last = new NeighborNode(distance, instance); } else {
if (isEmpty()) { m_First = m_Last = new NeighborNode(distance, instance); } else {
NeighborNode node = result.element(0).getFirst(); m_DistanceList = new double[result.element(0).currentLength()]; int i = 0; while (node != null) {
/** * Prunes the list to contain the k nearest neighbors. If there are multiple * neighbors at the k'th distance, all will be kept. * * @param k the number of neighbors to keep in the list. */ public void pruneToK(int k) { if (isEmpty()) { return; } if (k < 1) { k = 1; } int currentK = 0; double currentDist = m_First.m_Distance; NeighborNode current = m_First; for (; current.m_Next != null; current = current.m_Next) { currentK++; currentDist = current.m_Distance; if ((currentK >= k) && (currentDist != current.m_Next.m_Distance)) { m_Last = current; current.m_Next = null; break; } } }
/** * Prunes the list to contain the k nearest neighbors. If there are multiple * neighbors at the k'th distance, all will be kept. * * @param k the number of neighbors to keep in the list. */ public void pruneToK(int k) { if (isEmpty()) { return; } if (k < 1) { k = 1; } int currentK = 0; double currentDist = m_First.m_Distance; NeighborNode current = m_First; for (; current.m_Next != null; current = current.m_Next) { currentK++; currentDist = current.m_Distance; if ((currentK >= k) && (currentDist != current.m_Next.m_Distance)) { m_Last = current; current.m_Next = null; break; } } }
/** * Prints out the contents of the neighborlist. */ public void printList() { if (isEmpty()) { System.out.println("Empty list"); } else { NeighborNode current = m_First; while (current != null) { System.out.println("Node: instance " + current.m_Instance + ", distance " + current.m_Distance); current = current.m_Next; } System.out.println(); } }