Telfor - rešavanje problema mrežnog kodovanja upotrebom Grobnerovih baza

566 days ago by duleorlovic

N=14 #butterfly big R=PolynomialRing(ZZ,['x%s'%(p+1) for p in range(N)],N,order='lex') R.inject_variables() F=[x1*x7+x1*x5*x8+x3*x6*x8-1,x2*x7+x2*x5*x8+x4*x6*x8] F+=[x1*x9+x1*x5*x10+x3*x6*x10,x2*x9+x2*x5*x10+x4*x6*x10-1] F+=[x1*x5*x11+x3*x5*x11+x3*x12-1,x2*x5*x11+x4*x6*x11+x4*x12] F+=[x1*x5*x13+x3*x6*x13+x3*x14,x2*x5*x13+x4*x6*x13+x4*x14-1] 
       
Defining x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14
Defining x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14
g=Ideal(F).groebner_basis(algorithm='singular:std') lcm([x.lc() for x in g]) 
       
2
2
if sum([x.is_constant() for x in g])>1: print "potrebno je uraditi gcd svih" if sum([x.is_constant() for x in g])>0: if 1 in g: print "no solution" else: k=[x for x in g if x.is_constant()][0] char=prime_factors(k) print "karakteristike su",char else: k=lcm([x.lc() for x in g]) g1=Ideal(g+[k]).groebner_basis(algorithm='singular:std') k1=[x for x in g1 if x.is_constant()][0] char=[x for x in primes(10) if x not in prime_factors(k) or x in prime_factors(k1)] print "karakterisike su char=",char, " a lose karakteristike su",[x for x in primes(10) if x not in char] 
       
karakterisike su char= [2, 3, 5, 7]  a lose karakteristike su []
karakterisike su char= [2, 3, 5, 7]  a lose karakteristike su []
field_extension=1 char_iter=0 min_field=infinity while char_iter<len(char): print "da li u polju GF(",char[char_iter],"^",field_extension,") postoji resenje" if char[char_iter]^field_extension > min_field: print "ne vredi povecavati" field_extension=1 char_iter+=1 continue field_equations=[] for v in R.gens(): field_equations += [v^(char[char_iter]^field_extension)-v] I=Ideal(F+field_equations).change_ring(R.change_ring(GF(char[char_iter]^field_extension, name='alpha'))) g=I.groebner_basis() if 1 not in g: print "imamo resenje u polju velicine min_field=",char[char_iter]^field_extension min_field=char[char_iter]^field_extension char_iter+=1 field_extension=1 else: print "nema resenje za polje velicine ",char[char_iter]^field_extension field_extension+=1 
       
da li u polju GF( 2 ^ 1 ) postoji resenje
imamo resenje u polju velicine min_field= 2
da li u polju GF( 3 ^ 1 ) postoji resenje
ne vredi povecavati
da li u polju GF( 5 ^ 1 ) postoji resenje
ne vredi povecavati
da li u polju GF( 7 ^ 1 ) postoji resenje
ne vredi povecavati
da li u polju GF( 2 ^ 1 ) postoji resenje
imamo resenje u polju velicine min_field= 2
da li u polju GF( 3 ^ 1 ) postoji resenje
ne vredi povecavati
da li u polju GF( 5 ^ 1 ) postoji resenje
ne vredi povecavati
da li u polju GF( 7 ^ 1 ) postoji resenje
ne vredi povecavati
import networkx 
       
K=networkx.complete_graph(3) K.adj 
       
{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}
{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}
K.cho 
       
<networkx.classes.graph.Graph object at 0x622ba10>
<networkx.classes.graph.Graph object at 0x622ba10>
D=DiGraph(K) 
       
       
Digraph on 3 vertices
Digraph on 3 vertices
G=Graph(networkx.complete_graph(10)) 
       
G.delete_edge(9,3) 
       
Traceback (click to the left of this block for traceback)
...
NameError: name 'G' is not defined
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_3.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("Ry5kZWxldGVfZWRnZSg5LDMp"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>
    
  File "/tmp/tmpo43OXa/___code___.py", line 3, in <module>
    exec compile(u'G.delete_edge(_sage_const_9 ,_sage_const_3 )
  File "", line 1, in <module>
    
NameError: name 'G' is not defined
G.chromatic_number() 
       
3
3
G.show()