Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Graph polynomial construction

I wish to construct the graph polynomial (as given here of any given graph. To do so, I wrote the following code. But, the output was null. What needs to be modified in the following code to get the appropriate graph polynomial (the product of binomials corresponding each edge):

def grappoly(G):
R=PolynomialRing(ZZ,['x_'+str(k) for k in G.vertices()])
P=[]
R.inject_variables()
for i in G.vertices():
    for j in G.vertices():
        if set((i,j)).intersection(set(G.edges(labels=false)))==(i,j):
                         P=[R('x_'+str(i))-R('x_'+str(j))]
return P           
X=graphs.CompleteBipartiteGraph(5,5)
grappoly(X)

Thanks beforehand.

Graph polynomial construction

I wish to construct the graph polynomial (as given here of any given graph. To do so, I wrote the following code. But, the output was null. What needs to be modified in the following code to get the appropriate graph polynomial (the product of binomials corresponding each edge):

def grappoly(G):
R=PolynomialRing(ZZ,['x_'+str(k) for k in G.vertices()])
P=[]
R.inject_variables()
for i in G.vertices():
    for j in G.vertices():
         P=[]
         if set((i,j)).intersection(set(G.edges(labels=false)))==(i,j):
                         P=[R('x_'+str(i))-R('x_'+str(j))]
return P           
X=graphs.CompleteBipartiteGraph(5,5)
grappoly(X)

Thanks beforehand.

Graph polynomial construction

I wish to construct the graph polynomial (as given here of any given graph. To do so, I wrote the following code. But, the output was null. What needs to be modified in the following code to get the appropriate graph polynomial (the product of binomials corresponding each edge):

def grappoly(G): R=PolynomialRing(ZZ,['x_'+str(k) for k in G.vertices()]) P=[] R.inject_variables() for i in G.vertices(): for j in G.vertices(): P=[] P=1 if set((i,j)).intersection(set(G.edges(labels=false)))==(i,j): set((i,j)).intersection(set(G.edges()))==(i,j): P=[R('x_'+str(i))-R('x_'+str(j))] return P P=('x_'+str(i)-'x_'+str(j))*P return P
X=graphs.CompleteBipartiteGraph(5,5) grappoly(X)

grappoly(X)

Thanks beforehand.

Graph polynomial construction

I wish to construct the graph polynomial (as given here of any given graph. To do so, I wrote the following code. But, the output was null. What needs to be modified in the following code to get the appropriate graph polynomial (the product of binomials corresponding each edge):

 def grappoly(G):
  R=PolynomialRing(ZZ,['x_'+str(k) for k in G.vertices()])
  R.inject_variables()
  for i in G.vertices():
       for j in G.vertices():
            P=1
            if set((i,j)).intersection(set(G.edges()))==(i,j):
                          P=('x_'+str(i)-'x_'+str(j))*P
            return P 
X=graphs.CompleteBipartiteGraph(5,5) grappoly(X)

grappoly(X)

Thanks beforehand.

Graph polynomial construction

I wish to construct the graph polynomial (as given here ) of any given graph. To do so, I wrote the following code. But, the output was null. What needs to be modified in the following code to get the appropriate graph polynomial (the product of binomials corresponding each edge):

 def grappoly(G):
 R=PolynomialRing(ZZ,['x_'+str(k) for k in G.vertices()])
 R.inject_variables()
 for i in G.vertices():
      for j in G.vertices():
           P=1
           if set((i,j)).intersection(set(G.edges()))==(i,j):
                         P=('x_'+str(i)-'x_'+str(j))*P
           return P           
 X=graphs.CompleteBipartiteGraph(5,5)
 grappoly(X)

Thanks beforehand.