All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tagbio.umap.SearchGraph Maven / Gradle / Ivy

There is a newer version: 1.0
Show newest version
/*
 * 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];
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy