Ask Your Question

livvy94's profile - activity

2022-07-11 19:40:30 +0200 received badge  Nice Question (source)
2022-07-11 19:40:22 +0200 received badge  Famous Question (source)
2022-04-08 17:06:55 +0200 received badge  Famous Question (source)
2020-04-26 22:48:07 +0200 received badge  Notable Question (source)
2018-09-17 21:14:49 +0200 received badge  Popular Question (source)
2018-08-22 17:10:21 +0200 received badge  Notable Question (source)
2017-01-07 17:16:12 +0200 commented answer syntax error when doing try-except with the except command

@tmonteil @nbruin thank you :) looks like it was a indentation error as now it works. However once I enter pass and then press enter I end up with ....: not sage: how do I get out of this?

2017-01-04 17:38:01 +0200 commented answer syntax error when doing try-except with the except command

@tmonteil Thank you. I have now imported the MIPSolverException and tried again but I still appear to be getting the syntax error on except so am unable to put in print or pass?

2017-01-04 17:35:18 +0200 received badge  Editor (source)
2017-01-04 14:29:30 +0200 asked a question syntax error when doing try-except with the except command

I am running sage via virtual box and for some reason I am getting a syntax error for except. I was wondering if this wasn't available because I am using virtual box or if I am doing something wrong.

example below,

sage: def total_chromatic_number(G, certificate=False):
....:     nmax = len(G) + len(G.edges()) # trivial upper bound on the number of colors.
....:     for n in range(1,nmax+1):
....:         p = MixedIntegerLinearProgram()
....:         bv = p.new_variable(binary=True)
....:         be = p.new_variable(binary=True)
....:         for v in G.vertices():
....:             p.add_constraint(sum(bv[v,c] for c in range(n)) == 1)
....:         for e in G.edges(labels=False):
....:             p.add_constraint(sum(be[e,c] for c in range(n)) == 1)
....:         for v in G.vertices():
....:             for c in range(n):
....:                 p.add_constraint(bv[v,c] + sum(be[e,c] for e in G.edges_incident(v, labels=False)) <= 1)
....:         for v,w in G.edges(labels=False):
....:             for c in range(n):
....:                 p.add_constraint(bv[v,c] + bv[w,c] + be[(v,w),c] <= 1)
....:         try:    
....:             p.solve()
....:             if certificate:
....:                 bv_sol = p.get_values(bv)
....:                 be_sol = p.get_values(be)
....:                 coloration = {}
....:                 for v in G.vertices():
....:                     for c in range(n):
....:                         if bv_sol[v,c] == 1:
....:                             coloration[v] = c
....:                 for e in G.edges(labels=False):
....:                     for c in range(n):
....:                         if be_sol[e,c] == 1:
....:                             coloration[e] = c
....:                 return coloration
....:             else:
....:                 return n
....:         except MIPSolverException:

   File "<ipython-input-17-059a0ac5e5a6>", line 34
     except  MIPSolverException:
          ^
SyntaxError: invalid syntax
2017-01-03 16:04:53 +0200 commented answer can you find the total chromatic number (edge and vertices) of a graph?

@tmonteil ....: try:
....: p.solve() ....: if certificate: ....: bv_sol = p.get_values(bv) ....: be_sol = p.get_values(be) ....: coloration = {} ....: for v in G.vertices(): ....: for c in range(n): ....: if bv_sol[v,c] == 1: ....: coloration[v] = c ....: for e in G.edges(labels=False): ....: for c in range(n): ....: if be_sol[e,c] == 1: ....: coloration[e] = c ....: return coloration ....: else: ....: return n ....: except MIPSolverException: I then get syntax error for except

2017-01-03 13:04:56 +0200 received badge  Popular Question (source)
2016-12-28 17:42:47 +0200 commented answer can you find the total chromatic number (edge and vertices) of a graph?

@tmonteil thank you so much for all your help! hopefully this will be my last question/problem. I am getting a syntax error for except when i enter the penultimate line (except MIPSolverException)? thank you in advance.

2016-12-20 12:32:40 +0200 received badge  Supporter (source)
2016-12-01 14:44:20 +0200 commented answer can you find the total chromatic number (edge and vertices) of a graph?

@tmonteil Thank you for your response. I think I know how to create the constraints but I am confused as to how to do the first 2 points?

2016-11-26 22:21:35 +0200 received badge  Student (source)
2016-11-26 16:55:13 +0200 asked a question can you find the total chromatic number (edge and vertices) of a graph?

I' m trying to find the total chromatic number of a graph and I was wondering if anyone knew how to do this? I have found the edge and vertex chromatic number but am unable to join the 2.