# 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

b


3569  3569  from sage.graphs.cliquer import all_max_clique 
3570  3570  return sorted(all_max_clique(self)) 
3571  3571  
3572   def clique_maximum(self): 
 3572  def clique_maximum(self, algorithm="Cliquer"): 
3573  3573  """ 
3574  3574  Returns the vertex set of a maximal order complete subgraph. 
 3575  
 3576  INPUT: 
 3577  
 3578   ``algorithm``  the algorithm to be used : 
 3579  
 3580   If ``algorithm = "Cliquer"`` (default)  This wraps the C program 
 3581  Cliquer [NisOst2003]_. 
 3582  
 3583   If ``algorithm = "MILP"``, the problem is solved through a Mixed 
 3584  Integer Linear Program. 
 3585  
 3586  (see :class:`MixedIntegerLinearProgram <sage.numerical.mip>`) 
3575  3587  
3576  3588  .. NOTE:: 
3577  3589  
… 
… 

3582  3594  
3583  3595  This function is based on Cliquer [NisOst2003]_. 
3584  3596  
3585   EXAMPLES:: 
 3597  EXAMPLES: 
 3598  
 3599  Using Cliquer (default):: 
3586  3600  
3587  3601  sage: C=graphs.PetersenGraph() 
3588  3602  sage: C.clique_maximum() 
… 
… 

3591  3605  sage: C.clique_maximum() 
3592  3606  [1, 2, 3, 4] 
3593  3607  
 3608  Through a Linear Program:: 
 3609  
 3610  sage: len(C.clique_maximum(algorithm = "MILP")) 
 3611  4 
 3612  
 3613  TESTS: 
 3614  
 3615  Wrong algorithm:: 
 3616  
 3617  sage: C.clique_maximum(algorithm = "BFS") 
 3618  Traceback (most recent call last): 
 3619  ... 
 3620  NotImplementedError: Only 'MILP' and 'Cliquer' are supported. 
3594  3621  """ 
3595   from sage.graphs.cliquer import max_clique 
3596   return max_clique(self) 
 3622  if algorithm=="Cliquer": 
 3623  from sage.graphs.cliquer import max_clique 
 3624  return max_clique(self) 
 3625  elif algorithm == "MILP": 
 3626  return self.complement().independent_set(algorithm = algorithm) 
 3627  else: 
 3628  raise NotImplementedError("Only 'MILP' and 'Cliquer' are supported.") 
3597  3629  
3598  3630  def clique_number(self, algorithm="Cliquer", cliques=None): 
3599  3631  r""" 