Instantly share code, notes, and snippets.

Last active October 12, 2017 18:48
Show Gist options
• Save bmershon/41bc67cfedf95f7d196d to your computer and use it in GitHub Desktop.
Vietoris-Rips Complex (simplicial complex)

Please excuse the awful coding practices that may be found here.

This was more or less my first run at using D3 and JavaScript in an undergraduate math course (where writing code wasn't even expected, unless it was MATLAB). This was written before modular design, functional programming, and maturity had gripped the author to even a modest extent. This gadget (application seems too strong) was developed as if it were one colossal whiteboard exercise which permitted only small erasures and steady contributions over half of a semester.

The urge to go back and rearrange or modify in any way is strong, but I am choosing to leave this relic of sophomore year as a happy and messy memory of an assignment of which I am quite proud.

I love what I built, but I regret how it was built. I didn't know better.

A final paper was written about the design process of this and other gadgets created for MATH 412, taught by Paul Bendich during the Fall 2014 semester.

## Rips-Complex

This gadget demonstrates an application of the Rips-Complex to point-clouds sampled from continuous curves in the plane. The Rips-Complex allows us to calculate the number of connected components as well as the number of 1-cycles (loops) which appear at a given radius.

Points are sampled from an underlying curve with Gaussian noise applied. Persistent homology is computed by reducing the boundary matrix formed by the simplicial complex (at a given radius).

In order to add edges and triangles, a Delaunay triangulation using the existing vertices (points in the point clound) is calculated. Edges are added when the "balls" around the two vertices bounding an edge touch and the edge appears in the Delaunay triangulation.

Triangles are added immediately when their three 1-dimensional faces are present in the simplicial complex. As a result, what you see when the radius is scrubbed all the way to infinity is exactly the Delaunay triangulation of the point cloud.

The purpose of this gadget is to understand how Betti numbers change along the way as we increase the radius from zero to infinity.

The color of a triangle corresponds to the radius at which it appears. Note that the persistence of each 1-cycle formed can be encoded in a 1-dimensional persistence diagram. Such a diagram is replaced in this example by encoding the 1-dimensional persistence with a color scale, as the legend shows.

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
 name d figure eight "M100,50C0,100,150,350,300,350S300,100,400,50S650,250,500,250S200,0,100,50" loop "M106,109C68.05,155.05,135.4,356.25,166,375S257.05,252.9,310,234S502.65,273.9,519,249S480.95,89,419,68S143.95,62.949999999999996,106,109" squares "M260.0028381347656,269.0028381347656V76.00283813476562H102.00283813476562V215.00283813476562H310.0028381347656V143.00283813476562H425.0028381347656V401.0028381347656H318.0028381347656V270.0028381347656H482.0028381347656" pinched "M107.00283813476562,79.36221313476562C91.85283813476562,74.86221313476562,376.2528381347656,133.51221313476563,374.0028381347656,166.36221313476562S109.85283813476562,265.3622131347656,92.00283813476562,298.3622131347656S197.5528381347656,401.66221313476564,255.00283813476562,386.3622131347656S497.2028381347656,242.41221313476564,475.0028381347656,196.36221313476562S122.15283813476563,83.86221313476562,107.00283813476562,79.36221313476562" polygon "M165.00283813476562,292.0028381347656L150.00283813476562,84.00283813476562L347.0028381347656,83.00283813476562L562.0028686523438,170.00283813476562L434.0028381347656,364.0028381347656L277.0028381347656,420.0028381347656L68.00283813476562,414.0028381347656L67.00283813476562,205.00283813476562L319.0028381347656,197.00283813476562" torn "M110.00283813476562,237.72158813476562L129.83617146809894,219.88825480143228C149.66950480143228,202.05492146809894,189.33617146809894,166.38825480143228,213.66950480143228,196.05492146809894C238.00283813476562,225.72158813476562,247.00283813476562,320.7215881347656,263.83617146809894,335.38825480143225C280.66950480143225,350.05492146809894,305.33617146809894,284.38825480143225,314.0028381347656,294.88825480143225C322.66950480143225,305.38825480143225,315.33617146809894,392.05492146809894,365.6695098876953,374.38825480143225C416.00284830729163,356.7215881347656,524.0028584798176,234.72158813476562,546.6695251464844,161.2215887705485C569.336191813151,87.72158940633138,506.6695149739583,62.72159067789713,455.83617655436194,71.55492401123047C405.0028381347656,80.3882573445638,366.0028381347656,123.0549227396647,327.6695048014323,118.88825591405232C289.33617146809894,114.72158908843993,251.66950480143228,63.72159004211425,239.16950480143228,57.388256708780915C226.66950480143228,51.054923375447586,239.33617146809894,89.3882557551066,233.83617146809894,101.55492194493611C228.33617146809894,113.72158813476562,204.66950480143228,99.72158813476562,191.33617146809894,101.22158813476561C178.00283813476562,102.72158813476562,175.00283813476562,119.72158813476562,165.83617146809894,133.38825480143228C156.66950480143228,147.05492146809894,141.33617146809894,157.38825480143228,140.33617146809894,161.8882548014323C139.33617146809894,166.38825480143228,152.66950480143228,165.05492146809894,148.83617146809894,171.55492146809894C145.00283813476562,178.05492146809894,124.00283813476561,192.38825480143228,113.5028381347656,199.55492146809897L103.00283813476562,206.72158813476562"
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

Show Sampled Curve