# Ticket #11944: trac_11944.patch

File trac_11944.patch, 2.3 KB (added by ncohen, 8 years ago)
• ## sage/graphs/graph.py

```# HG changeset patch
# User Nathann Cohen <nathann.cohen@gmail.com>
# Date 1319209256 -7200
# Node ID 297282833ed918a052ed25207f6fc79df5187e00
# Parent  856eabddb023ed30678c3bc85a6f378914ff68dc
trac 11944 -- Update Graph.clique_maximum to use MILP

diff --git a/sage/graphs/graph.py b/sage/graphs/graph.py```
 a from sage.graphs.cliquer import all_max_clique return sorted(all_max_clique(self)) def clique_maximum(self): def clique_maximum(self,  algorithm="Cliquer"): """ Returns the vertex set of a maximal order complete subgraph. INPUT: - ``algorithm`` -- the algorithm to be used : - If ``algorithm = "Cliquer"`` (default) - This wraps the C program Cliquer [NisOst2003]_. - If ``algorithm = "MILP"``, the problem is solved through a Mixed Integer Linear Program. (see :class:`MixedIntegerLinearProgram `) .. NOTE:: This function is based on Cliquer [NisOst2003]_. EXAMPLES:: EXAMPLES: Using Cliquer (default):: sage: C=graphs.PetersenGraph() sage: C.clique_maximum() sage: C.clique_maximum() [1, 2, 3, 4] Through a Linear Program:: sage: len(C.clique_maximum(algorithm = "MILP")) 4 TESTS: Wrong algorithm:: sage: C.clique_maximum(algorithm = "BFS") Traceback (most recent call last): ... NotImplementedError: Only 'MILP' and 'Cliquer' are supported. """ from sage.graphs.cliquer import max_clique return max_clique(self) if algorithm=="Cliquer": from sage.graphs.cliquer import max_clique return max_clique(self) elif algorithm == "MILP": return self.complement().independent_set(algorithm = algorithm) else: raise NotImplementedError("Only 'MILP' and 'Cliquer' are supported.") def clique_number(self, algorithm="Cliquer", cliques=None): r"""