[(1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, 3), (2, 6), (2, 7), (2, 8), (3, 5), (3, 7), (3, 8), (4, 5), (4, 6), (4, 7), (5, 8), (6, 8), (7, 8)]] numbersOfComplexSolutions = [ 128, 160, 128, 112, 96, 96, 96, 96, 80, 80, 80, 128, 96, 96, 96, 80, 96, 96 ] names = [ 'G128a', 'G160', 'G128b', 'G112', 'G96a', 'G96b', 'G96c', 'G96d', 'G80a', 'G80b', 'G80c', 'G128c', 'G96', 'G96e', 'G96f', 'G80d', 'G96g', 'G96h' ] for N in range(2, len(graphs)): lengths = getEdgeLengthsByEmbedding('edges', [v1, v2, v3, v4, v5, v6, v7, v8], edges=graphs[N]) print graphs[N] start = time.time() # we run the sampling method based on coupler curves alg = AlgRealEmbeddings('edges', name=names[N], edges=graphs[N], num_sols=numbersOfComplexSolutions[N], allowedNumberOfMissing=10) lengths_final = alg.findMoreEmbeddings(lengths) print '\n\nSampling time: ', time.time() - start print '\n\nChecking and summary ' G = GraphEmbedding(lengths_final,
The starting edge lengths are chosen randomly so that top, ring and bottom edges have similar lengths, respectively. ''' print __doc__ import sys sys.path.append('..') from graphEmbeddings3D.algRealEmbeddings import AlgRealEmbeddings from graphEmbeddings3D.graphEmbedding import getEdgeLengthsByEmbedding from random import uniform a = -0.05 b = 0.05 v1 = [0.6 + uniform(a, b), 0.6 + uniform(a, b), -3.0 + uniform(a, b)] v2 = [-1.0 + uniform(a, b), uniform(a, b), uniform(a, b)] v4 = [-1.0 + uniform(a, b), uniform(a, b), uniform(a, b)] v6 = [-1.0 + uniform(a, b), uniform(a, b), uniform(a, b)] v3 = [1.0 + uniform(a, b), uniform(a, b), uniform(a, b)] v5 = [1.0 + uniform(a, b), uniform(a, b), uniform(a, b)] v7 = [1.0 + uniform(a, b), uniform(a, b), uniform(a, b)] v8 = [0.6 + uniform(a, b), 0.6 + uniform(a, b), 1.0 + uniform(a, b)] lengths = getEdgeLengthsByEmbedding('Ring8vertices', [v1, v2, v3, v4, v5, v6, v7, v8]) alg = AlgRealEmbeddings('Ring8vertices', name='8Ring_rnd_TBR') alg.findMoreEmbeddings(lengths)
from random import uniform #48 embedding for G48 a = -0.05 b = 0.05 c = -10.0 d = 10.0 edges_G160=[(1, 2), (1, 3), (1, 4), (1, 8), (2, 3), (2, 5), (2, 6), (2, 8), (3, 4), (3, 5), (3, 7),(4, 7), (4, 8), (5, 6), (5, 7), (6, 7), (6, 8), (7, 8)] #try: v3 = [0, 0, 0] v1 = [0, 5.73225265711452, 0] v2 = [0, 0.148291560665423, 3.30491899417522] v5 = [-3.1508917850189, 0.846961251730797, 0.259525376012296] v7 = [-2.49285516161801, 1.67204766459525, -0.558220040757827] v4 = [-2.59381676560345, 1.54400553897266, -0.398999543683517] v8 = [-1.69450165498139, 1.01237857741641, -0.346180158496239] v6 = [-3.1508917850189+uniform(a,b), 0.846961251730797+uniform(a,b), 0.259525376012296+uniform(a,b)] lengths = getEdgeLengthsByEmbedding('edges', [v1, v2, v3, v4, v5, v6, v7, v8], edges=edges_G160) alg = AlgRealEmbeddings('edges', name='G160', edges=edges_G160, num_sols=160, allowedNumberOfMissing=4, moreSamplingSubgraphs=False) lengths_final =alg.findMoreEmbeddings(lengths) G = GraphEmbedding(lengths_final, 'edges', num_sols=160) print 'There are ', len(G.findEmbeddings()['real']), 'real embeddings with the following edge lengths:' print lengths_final #except: # pass # ---------------------------------
from graphEmbeddings3D.graphEmbedding import getEdgeLengthsByEmbedding, GraphEmbedding from random import uniform import time a = -1.0 b = 1.0 # a random embedding is taken: v1 = [uniform(a, b), uniform(a, b), uniform(a, b)] v2 = [uniform(a, b), uniform(a, b), uniform(a, b)] v3 = [uniform(a, b), uniform(a, b), uniform(a, b)] v4 = [uniform(a, b), uniform(a, b), uniform(a, b)] v5 = [uniform(a, b), uniform(a, b), uniform(a, b)] v6 = [uniform(a, b), uniform(a, b), uniform(a, b)] # edge lengths are given as the distances in the embedding lengths = getEdgeLengthsByEmbedding('Max6vertices', [v1, v2, v3, v4, v5, v6]) # or the following edge lengths yields ones with 16 real embeddings: #lengths = {(1, 3): 0.5308353556228526, (5, 6): 1.8056034169357076, (2, 6): 2.4456570316770256, (2, 3): 0.8512597859002053, # (3, 5): 1.2853151143150572, (1, 2): 1.1757548283222, (4, 6): 0.9879010951471968, (1, 5): 0.7810003670625068, # (4, 5): 1.6175092476119708, (1, 6): 1.4488010671291325, (3, 4): 1.1784501009786457, (2, 4): 1.9763357382306461} start = time.time() # we run the sampling method based on coupler curves alg = AlgRealEmbeddings('Max6vertices', num_phi=5, num_theta=5, name='random6vert') lengths_final = alg.findMoreEmbeddings(lengths, allowed_repetition=2) print '\n\nSampling time: ', time.time() - start
from graphEmbeddings3D.graphEmbedding import getEdgeLengthsByEmbedding, GraphEmbedding from random import uniform a = -0.2 b = 0.2 for i in range(0, 100): v1 = [0.6 + uniform(a, b), 0.6 + uniform(a, b), -3.0 + uniform(a, b)] v2 = [-1.0 + uniform(a, b), uniform(a, b), uniform(a, b)] v3 = [1.0 + uniform(a, b), uniform(a, b), uniform(a, b)] v4 = [-1.0 + uniform(a, b), uniform(a, b), uniform(a, b)] v5 = [1.0 + uniform(a, b), uniform(a, b), uniform(a, b)] v6 = [1.0 + uniform(a, b), 1.0 + uniform(a, b), uniform(a, b)] v7 = [0.6 + uniform(a, b), 0.6 + uniform(a, b), 1.0 + uniform(a, b)] lengths = getEdgeLengthsByEmbedding('Max7vertices', [v1, v2, v3, v4, v5, v6, v7]) alg = AlgRealEmbeddings('Max7vertices', name='random7vert') lengths_7 = alg.findMoreEmbeddings(lengths, required_num=44) G = GraphEmbedding(lengths_7, 'Max7vertices') v1, v2, v3, v4, v5, v6, v7 = G.getEmbedding() v8 = [0, 0, 0] lengths = getEdgeLengthsByEmbedding('Max8vertices', [v1, v2, v3, v4, v5, v6, v7, v8]) alg2 = AlgRealEmbeddings('Max8vertices', name='from_rnd7to8') alg2.findMoreEmbeddings(lengths) del alg
import sys sys.path.append('..') from graphEmbeddings3D.algRealEmbeddings import AlgRealEmbeddings from graphEmbeddings3D.graphEmbedding import getEdgeLengthsByEmbedding from random import uniform a = -5.0 b = 5.0 v1 = [uniform(a, b), uniform(a, b), uniform(a, b)] v2 = [uniform(a, b), uniform(a, b), uniform(a, b)] v3 = [uniform(a, b), uniform(a, b), uniform(a, b)] v4 = [uniform(a, b), uniform(a, b), uniform(a, b)] v5 = [uniform(a, b), uniform(a, b), uniform(a, b)] v6 = [uniform(a, b), uniform(a, b), uniform(a, b)] v7 = [uniform(a, b), uniform(a, b), uniform(a, b)] lengths = getEdgeLengthsByEmbedding('7vert32a', [v1, v2, v3, v4, v5, v6, v7]) alg = AlgRealEmbeddings('7vert32a', name='7vert32a_random', num_phi=12, num_theta=12) alg.findMoreEmbeddings(lengths) #one of the obtained edge lengths: #lengths = {(1, 2): 10.9464978614277, (4, 7): 8.7388471903030389, (1, 3): 6.27469003969716, (6, 7): 9.284894093430244, # (5, 6): 9.229604229826325, (5, 7): 7.8831186688053965, (1, 4): 8.062543016998301, (1, 6): 11.559732906664415, # (3, 6): 8.255957517599734, (2, 3): 8.827097289782333, (3, 7): 5.617334110160578, (2, 5): 9.741464052378111, # (3, 4): 6.1089666048644204, (2, 4): 8.949700966931744, (3, 5): 5.5980614315661095}
d = 10.0 try: v1 = [uniform(a, b), uniform(a, b), uniform(a, b)] v8 = [uniform(a, b), uniform(a, b), uniform(a, b)] v2 = [1.0 + uniform(a, b), uniform(a, b), uniform(a, b)] v4 = [1.0 + uniform(a, b), uniform(a, b), uniform(a, b)] v6 = [uniform(a, b), 1.0 + uniform(a, b), uniform(a, b)] v7 = [uniform(a, b), 1.0 + uniform(a, b), uniform(a, b)] v3 = [uniform(a, b), uniform(a, b), 1.0 + uniform(a, b)] v5 = [uniform(a, b), uniform(a, b), 1.0 + uniform(a, b)] lengths = getEdgeLengthsByEmbedding('Max8vertices_distSyst', [v1, v2, v3, v4, v5, v6, v7, v8]) alg = AlgRealEmbeddings('Max8vertices_distSyst', name='8vert_random_fromTetrahedron_dist') alg.findMoreEmbeddings(lengths) except: pass # --------------------------------- try: v1 = [uniform(c, d), uniform(c, d), uniform(c, d)] v8 = [uniform(c, d), uniform(c, d), uniform(c, d)] v2 = [uniform(a, b), uniform(a, b), uniform(a, b)] v5 = [uniform(a, b), uniform(a, b), uniform(a, b)] v6 = [uniform(c, d), uniform(c, d), uniform(c, d)]