Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vertex cover #7600

Closed
nathanncohen mannequin opened this issue Dec 4, 2009 · 10 comments
Closed

Vertex cover #7600

nathanncohen mannequin opened this issue Dec 4, 2009 · 10 comments

Comments

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Dec 4, 2009

As the title says, this patch implements Graph.vertex_cover.

You could be in need of #7270 and GLPK from http://sagemath.org/packages/optional/glpk-4.38.p4.spkg depending on the version of Sage you are using !!!

CC: @sagetrac-kevin-stueve

Component: graph theory

Author: Nathann Cohen

Reviewer: Robert Miller

Merged: sage-4.3.rc1

Issue created by migration from https://trac.sagemath.org/ticket/7600

@nathanncohen nathanncohen mannequin added this to the sage-4.3.1 milestone Dec 4, 2009
@nathanncohen nathanncohen mannequin assigned rlmill Dec 4, 2009
@nathanncohen nathanncohen mannequin added the s: needs review label Dec 4, 2009
@nathanncohen

This comment has been minimized.

@sagetrac-kevin-stueve
Copy link
Mannequin

sagetrac-kevin-stueve mannequin commented Dec 9, 2009

comment:3

I've never reviewed a patch before.

We were just talking about vertex cover in my algorithms class the other day.

The three problems:

  1. Does G have a clique of size m or more?

  2. Is there a vertex cover of size m or less for G?

  3. Does G contain an independent set of size m or more?

are all polynomially reducible to each other.

exercise 9, p 403, The Design and Analysis of Algorithms, 2nd Edition

I'm not aware if those other problems are implemented in Sage. If not, maybe a ticket should be created.

3048 As vertex cover is a NP-complete problem

IMO, would be better with the word "an" in place of "a".

Kevin Stueve

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Dec 9, 2009

comment:5

Hello !!!!

You are right, these three are reducible to each other ! Actually, Sage already has an algorithm for 1) and 3) through Cliquer, which is way more efficient that LinearProgramming... I will immediately add several lines to the patch to let it use Cliquer by default, and use LP if the users wants it ( and this way we can control the respective values of the two algorithms ) :-)

Thank you very much for your remark, this should speed up the algorithm amazingly ! :-)

Nathann

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Dec 9, 2009

comment:6

Done ! Thank you very much for your help ! :-)
Besides, as the algorithm Cliquer does not require GLPK or CBC, there is a way for everybody to compute a vertex cover now :-)

Nathann

@rlmill
Copy link
Mannequin

rlmill mannequin commented Dec 15, 2009

comment:7

oops:

sage: vc2 = g.vertex_cover(algorithm="Cliquer")
---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)

/Users/rlmill/.sage/temp/rlm_book.local/98560/_Users_rlmill__sage_init_sage_0.py in <module>()

/Users/rlmill/sage-4.3.rc0/local/lib/python2.6/site-packages/sage/graphs/graph.pyc in vertex_cover(self, algorithm, value_only, log)
   3325                 return self.order()-len(independent)
   3326             else:
-> 3327                 return set(g.vertices()).difference(set(independent))
   3328 
   3329         elif algorithm=="MILP":

UnboundLocalError: local variable 'g' referenced before assignment

@rlmill rlmill mannequin added s: needs work and removed s: needs review labels Dec 15, 2009
@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Dec 16, 2009

Attachment: trac_7600.patch.gz

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Dec 16, 2009

comment:8

fixed !

@rlmill
Copy link
Mannequin

rlmill mannequin commented Dec 16, 2009

Reviewer: Robert Miller

@rlmill
Copy link
Mannequin

rlmill mannequin commented Dec 16, 2009

Author: Nathann Cohen

@mwhansen
Copy link
Contributor

Merged: sage-4.3.rc1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant