Created
December 18, 2013 02:59
-
-
Save jackmaney/8016614 to your computer and use it in GitHub Desktop.
First example in the javaPlex tutorial...in Java (instead of Matlab)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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