@@ -344,7 +344,7 @@ def chromatic_number(G):
344344
345345from sage .numerical .mip import MIPSolverException
346346
347- def vertex_coloring (g , k = None , value_only = False , hex_colors = False , solver = None , verbose = 0 ):
347+ def vertex_coloring (g , k = None , value_only = False , hex_colors = False , solver = None , verbose = 0 ):
348348 r"""
349349 Computes the chromatic number of the given graph or tests its
350350 `k`-colorability. See :wikipedia:`Graph_coloring` for
@@ -458,7 +458,7 @@ class :class:`MixedIntegerLinearProgram
458458 while True :
459459 # tries to color the graph, increasing k each time it fails.
460460 tmp = vertex_coloring (g , k = k , value_only = value_only ,
461- hex_colors = hex_colors , verbose = verbose )
461+ hex_colors = hex_colors , solver = solver , verbose = verbose )
462462 if tmp is not False :
463463 if value_only :
464464 return k
@@ -486,15 +486,16 @@ class :class:`MixedIntegerLinearProgram
486486 tmp = vertex_coloring (g .subgraph (component ), k = k ,
487487 value_only = value_only ,
488488 hex_colors = hex_colors ,
489- verbose = verbose )
489+ solver = solver , verbose = verbose )
490490 if tmp is False :
491491 return False
492492 return True
493493 colorings = []
494494 for component in g .connected_components ():
495495 tmp = vertex_coloring (g .subgraph (component ), k = k ,
496496 value_only = value_only ,
497- hex_colors = False , verbose = verbose )
497+ hex_colors = False ,
498+ solver = solver , verbose = verbose )
498499 if tmp is False :
499500 return False
500501 colorings .append (tmp )
@@ -525,11 +526,11 @@ class :class:`MixedIntegerLinearProgram
525526 return vertex_coloring (g .subgraph (list (vertices )), k = k ,
526527 value_only = value_only ,
527528 hex_colors = hex_colors ,
528- verbose = verbose )
529+ solver = solver , verbose = verbose )
529530 value = vertex_coloring (g .subgraph (list (vertices )), k = k ,
530531 value_only = value_only ,
531532 hex_colors = False ,
532- verbose = verbose )
533+ solver = solver , verbose = verbose )
533534 if value is False :
534535 return False
535536 while len (deg ) > 0 :
@@ -543,8 +544,8 @@ class :class:`MixedIntegerLinearProgram
543544 else :
544545 return value
545546
546- p = MixedIntegerLinearProgram (maximization = True , solver = solver )
547- color = p .new_variable (binary = True )
547+ p = MixedIntegerLinearProgram (maximization = True , solver = solver )
548+ color = p .new_variable (binary = True )
548549
549550 # a vertex has exactly one color
550551 for v in g .vertices ():
@@ -583,10 +584,9 @@ class :class:`MixedIntegerLinearProgram
583584 else :
584585 return classes
585586
586- def grundy_coloring (g , k , value_only = True , solver = None , verbose = 0 ):
587+ def grundy_coloring (g , k , value_only = True , solver = None , verbose = 0 ):
587588 r"""
588- Computes the worst-case of a first-fit coloring with less than `k`
589- colors.
589+ Computes the worst-case of a first-fit coloring with less than `k` colors.
590590
591591 Definition :
592592
@@ -667,24 +667,24 @@ def grundy_coloring(g, k, value_only = True, solver = None, verbose = 0):
667667 from sage .numerical .mip import MixedIntegerLinearProgram
668668 from sage .numerical .mip import MIPSolverException
669669
670- p = MixedIntegerLinearProgram (solver = solver )
670+ p = MixedIntegerLinearProgram (solver = solver )
671671
672672 # List of colors
673673 classes = range (k )
674674
675675 # b[v,i] is set to 1 if and only if v is colored with i
676- b = p .new_variable (binary = True )
676+ b = p .new_variable (binary = True )
677677
678678 # is_used[i] is set to 1 if and only if color [i] is used by some
679679 # vertex
680- is_used = p .new_variable (binary = True )
680+ is_used = p .new_variable (binary = True )
681681
682682 # Each vertex is in exactly one class
683683 for v in g :
684684 p .add_constraint (p .sum ( b [v ,i ] for i in classes ), max = 1 , min = 1 )
685685
686686 # Two adjacent vertices have different classes
687- for u ,v in g .edges (labels = None ):
687+ for u ,v in g .edges (labels = None ):
688688 for i in classes :
689689 p .add_constraint (b [v ,i ] + b [u ,i ], max = 1 )
690690
@@ -710,7 +710,7 @@ def grundy_coloring(g, k, value_only = True, solver = None, verbose = 0):
710710 p .set_objective ( p .sum ( is_used [i ] for i in classes ) )
711711
712712 try :
713- obj = p .solve (log = verbose , objective_only = value_only )
713+ obj = p .solve (log = verbose , objective_only = value_only )
714714 from sage .rings .integer import Integer
715715 obj = Integer (obj )
716716
@@ -734,7 +734,7 @@ def grundy_coloring(g, k, value_only = True, solver = None, verbose = 0):
734734 return obj , coloring
735735
736736
737- def b_coloring (g , k , value_only = True , solver = None , verbose = 0 ):
737+ def b_coloring (g , k , value_only = True , solver = None , verbose = 0 ):
738738 r"""
739739 Computes a b-coloring with at most k colors that maximizes the
740740 number of colors, if such a coloring exists
@@ -850,7 +850,7 @@ def b_coloring(g, k, value_only = True, solver = None, verbose = 0):
850850 k = m
851851
852852
853- p = MixedIntegerLinearProgram (solver = solver )
853+ p = MixedIntegerLinearProgram (solver = solver )
854854
855855 # List of possible colors
856856 classes = range (k )
@@ -911,7 +911,7 @@ def b_coloring(g, k, value_only = True, solver = None, verbose = 0):
911911
912912
913913 try :
914- obj = p .solve (log = verbose , objective_only = value_only )
914+ obj = p .solve (log = verbose , objective_only = value_only )
915915 from sage .rings .integer import Integer
916916 obj = Integer (obj )
917917
@@ -1413,7 +1413,7 @@ def add(uv, i):
14131413 return answer
14141414
14151415
1416- def acyclic_edge_coloring (g , hex_colors = False , value_only = False , k = 0 , solver = None , verbose = 0 ):
1416+ def acyclic_edge_coloring (g , hex_colors = False , value_only = False , k = 0 , solver = None , verbose = 0 ):
14171417 r"""
14181418 Computes an acyclic edge coloring of the current graph.
14191419
0 commit comments