| Home | Trees | Indices | Help |
|---|
|
|
Exact Cover Problem via Dancing Links
|
|||
| DLXMatrix | |||
|
|||
|
|||
|
|||
|
|||
ROOTNODE = 0
|
|||
LEFT = 0
|
|||
RIGHT = 1
|
|||
UP = 2
|
|||
DOWN = 3
|
|||
COLUMN = 4
|
|||
INDEX = 5
|
|||
COUNT = 5
|
|||
|
|||
Utilizes A. Ajanki's DLXMatrix class to solve the exact cover
problem on the matrix M (treated as a dense binary matrix).
EXAMPLES:
sage: M = Matrix([[1,1,0],[1,0,1],[0,1,1]]) #no exact covers
sage: for cover in AllExactCovers(M):
... print cover
sage: M = Matrix([[1,1,0],[1,0,1],[0,0,1],[0,1,0]]) #two exact covers
sage: for cover in AllExactCovers(M):
... print cover
[(1, 1, 0), (0, 0, 1)]
[(1, 0, 1), (0, 1, 0)]
|
Utilizes A. Ajanki's DLXMatrix class to solve the exact cover
problem on the matrix M (treated as a dense binary matrix).
EXAMPLES:
sage: M = Matrix([[1,1,0],[1,0,1],[0,1,1]]) #no exact covers
sage: print OneExactCover(M)
None
sage: M = Matrix([[1,1,0],[1,0,1],[0,0,1],[0,1,0]]) #two exact covers
sage: print OneExactCover(M)
[(1, 1, 0), (0, 0, 1)]
|
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0beta1 on Thu Jul 17 04:23:25 2008 | http://epydoc.sourceforge.net |