tagbio.umap.SearchGraph Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of external-umap-java Show documentation
Show all versions of external-umap-java Show documentation
Umap implementation in Java, included from umap-java github project.
/*
* BSD 3-Clause License
* Copyright (c) 2017, Leland McInnes, 2019 Tag.bio (Java port).
* See LICENSE.txt.
*/
package tagbio.umap;
import java.util.Set;
import java.util.TreeSet;
/**
* Stores unordered pairs.
* @author Sean A. Irvine
* @author Richard Littin
*/
class SearchGraph {
private final TreeSet[] mRows;
@SuppressWarnings("unchecked")
SearchGraph(final int rows) {
mRows = (TreeSet[]) new TreeSet[rows];
for (int k = 0; k < rows; ++k) {
mRows[k] = new TreeSet<>();
}
}
/**
* Set the unordered pair of instances.
* @param x instance index
* @param y instance index
*/
void set(final int x, final int y) {
mRows[x].add(y);
mRows[y].add(x);
}
/**
* Set of indices for an instance.
* @param row instance number
* @return set of instance numbers
*/
Set row(final int row) {
return mRows[row];
}
}