# Ticket #10044: trac_10044-python.patch

File trac_10044-python.patch, 4.3 KB (added by ncohen, 9 years ago)
• ## sage/graphs/graph.py

# HG changeset patch
# User Nathann Cohen <nathann.cohen@gmail.com>
# Date 1285889116 -7200
diff -r 2c6977d800b5 -r 0c47c4999c2f sage/graphs/graph.py
 a return first_coloring(self, hex_colors=hex_colors) else: raise ValueError("The 'algorithm' keyword must be set to either 'DLX' or 'MILP'.") def fractional_chromatic_index(self, verbose_constraints = 0, verbose = 0): r""" Computes the fractional chromatic index of self The fractional chromatic index is a relaxed version of edge-coloring. An edge coloring of a graph being actually a covering of its edges into the smallest possible number of matchings, the fractional chromatic index of a graph G is the smallest real value \chi_f(G) such that there exists a list of matchings M_1, ..., M_k of G and coefficients \alpha_1, ..., \alpha_k with the property that each edge is covered by the matchings in the following relaxed way .. MATH:: \forall e \in E(G), \sum_{e \in M_i} \alpha_i \geq 1 For more information, see the Wikipedia article on fractional coloring _. ALGORITHM: The fractional chromatic index is computed through Linear Programming through its dual. The LP solved by sage is actually: .. MATH:: \mbox{Maximize : }&\sum_{e\in E(G)} r_{e}\\ \mbox{Such that : }&\\ &\forall M\text{ matching }\subseteq G, \sum_{e\in M}r_{v}\leq 1\\ INPUT: - verbose_constraints -- whether to display which constraints are being generated. - verbose -- level of verbosity required from the LP solver .. NOTE:: This implementation can be improved by computing matchings through a LP formulation, and not using the Python implementation of Edmonds' algorithm (which requires to copy the graph, etc). It may be more efficient to write the matching problem as a LP, as we would then just have to update the weights on the edges between each call to solve (and so avoiding the generation of all the constraints). EXAMPLE: The fractional chromatic index of a C_5 is 5/2:: sage: g = graphs.CycleGraph(5) sage: g.fractional_chromatic_index() 2.5 """ from sage.numerical.mip import MixedIntegerLinearProgram, Sum g = self.copy() p = MixedIntegerLinearProgram() # One variable per edge r = p.new_variable(dim = 2) R = lambda x,y : r[x][y] if x