Skip to content

Instantly share code, notes, and snippets.

@jackmaney
Created December 18, 2013 02:59
Show Gist options
  • Save jackmaney/8016614 to your computer and use it in GitHub Desktop.
Save jackmaney/8016614 to your computer and use it in GitHub Desktop.
First example in the javaPlex tutorial...in Java (instead of Matlab)
import edu.stanford.math.plex4.api.Plex4;
import edu.stanford.math.plex4.homology.barcodes.BarcodeCollection;
import edu.stanford.math.plex4.homology.chain_basis.Simplex;
import edu.stanford.math.plex4.homology.interfaces.AbstractPersistenceAlgorithm;
import edu.stanford.math.plex4.streams.impl.ExplicitSimplexStream;
public class BasicHomology {
public static void main(String[] args) {
ExplicitSimplexStream stream = new ExplicitSimplexStream();
stream.addVertex(0);
stream.addVertex(1);
stream.addVertex(2);
stream.addElement(new int[] {0,1});
stream.addElement(new int[] {1,2});
stream.addElement(new int[] {2,0});
stream.finalizeStream();
System.out.println("Size of complex: " + stream.getSize());
AbstractPersistenceAlgorithm<Simplex> persistence
= Plex4.getModularSimplicialAlgorithm(3, 2);
BarcodeCollection<Double> circle_intervals
= persistence.computeIntervals(stream);
System.out.println(circle_intervals);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment