Beispiel #1
0
colors_grph_3=[sh.localHomology(3,cplx,[spx],True) for spx in cplx_grph]

endTime = tm.time()
print "\n**** Total time = %f s ****\n" % (endTime-startTime)

print "creating locations array"
locations = [[coords[states[i]][0], -coords[states[i]][1]] for i in range(1,50)]
locations = [[0,0]] + locations

plt.figure(figsize=(24,16), tight_layout=True)
#plt.figure()
plt.hold(True)
plt.subplot(311)
plt.title("H1")
print "plotting complex 1"
pc.plot_complex(locations,cplx_grph,colors_grph_1)
x_offset = 25
y_offset = 35
for k, v in coords.iteritems():
    plt.text(v[0]-x_offset, -v[1]+y_offset, k, weight='bold', size=18)
plt.axis('off')
plt.tight_layout()
plt.subplot(312)
plt.title("H2")
print "plotting complex 2"
pc.plot_complex(locations,cplx_grph,colors_grph_2)
for k, v in coords.iteritems():
    plt.text(v[0]-x_offset, -v[1]+y_offset, k, weight='bold', size=18)
plt.axis('off')
plt.tight_layout()
plt.subplot(313)
Beispiel #2
0
                cplx += [
                    [i * len(angles) + j, i * len(angles), (i - 1) * len(angles) + j],
                    [(i - 1) * len(angles), (i - 1) * len(angles) + j, i * len(angles)],
                ]
            else:
                cplx += [
                    [i * len(angles) + j, i * len(angles) + j + 1, (i - 1) * len(angles) + j],
                    [(i - 1) * len(angles) + j + 1, (i - 1) * len(angles) + j, i * len(angles) + j + 1],
                ]


startTime = tm.time()

cplx_annulus = cplx + sh.ksimplices(cplx, 1) + sh.ksimplices(cplx, 0)

print "colors_annulus_1"
colors_annulus_1 = [sh.localHomology(1, cplx, [spx], True) for spx in cplx_annulus]
print "colors_annulus_2"
colors_annulus_2 = [sh.localHomology(2, cplx, [spx], True) for spx in cplx_annulus]

endTime = tm.time()
print "\n**** Total time = %f s ****\n" % (endTime - startTime)

plt.figure()
plt.hold(True)
plt.subplot(121)
pc.plot_complex(locations_annulus, cplx_annulus, colors_annulus_1)
plt.subplot(122)
pc.plot_complex(locations_annulus, cplx_annulus, colors_annulus_2)
plt.savefig("annulus.png")
Beispiel #3
0
                cplx += [[
                    i * len(angles) + j, i * len(angles) + j + 1,
                    (i - 1) * len(angles) + j
                ],
                         [(i - 1) * len(angles) + j + 1,
                          (i - 1) * len(angles) + j, i * len(angles) + j + 1]]

startTime = tm.time()

cplx_annulus = cplx + sh.ksimplices(cplx, 1) + sh.ksimplices(cplx, 0)

print 'colors_annulus_1'
colors_annulus_1 = [
    sh.localHomology(1, cplx, [spx], True) for spx in cplx_annulus
]
print 'colors_annulus_2'
colors_annulus_2 = [
    sh.localHomology(2, cplx, [spx], True) for spx in cplx_annulus
]

endTime = tm.time()
print "\n**** Total time = %f s ****\n" % (endTime - startTime)

plt.figure()
plt.hold(True)
plt.subplot(121)
pc.plot_complex(locations_annulus, cplx_annulus, colors_annulus_1)
plt.subplot(122)
pc.plot_complex(locations_annulus, cplx_annulus, colors_annulus_2)
plt.savefig('annulus.png')
Beispiel #4
0
import numpy.random as random
import matplotlib.pyplot as plt
import simplicialHomology as sh
import plotComplex as pc

# Example: A "thick" graph
startTime = tm.time()
random.seed(100)

locations = []
while len(locations) < 100:
    loc = random.rand(2)
    if np.sqrt((loc[0] - 0.5)**2 + (loc[1] - 0.5)**2) < 0.5:
        locations.append(loc)
cplx = sh.vietorisRips(locations, 0.1, maxdim=2)
cplx_grph = sh.ksimplices(cplx, 0) + sh.ksimplices(cplx, 1) + sh.ksimplices(
    cplx, 2)
colors_grph_1 = [sh.localHomology(1, cplx, [spx], True) for spx in cplx_grph]
colors_grph_2 = [sh.localHomology(2, cplx, [spx], True) for spx in cplx_grph]

endTime = tm.time()
print "\n**** Total time = %f s ****\n" % (endTime - startTime)

plt.figure()
plt.hold(True)
plt.subplot(121)
pc.plot_complex(locations, cplx_grph, colors_grph_1)
plt.subplot(122)
pc.plot_complex(locations, cplx_grph, colors_grph_2)
plt.savefig('thick_graph.png')