-
Notifications
You must be signed in to change notification settings - Fork 3
/
dlx.h
59 lines (50 loc) · 1.26 KB
/
dlx.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef _DLX_H
#define _DLX_H
#include <stdint.h>
#include "debug_print.h"
struct dlx_col;
struct dlx_node;
struct dlx_node {
struct dlx_node *lx;
struct dlx_node *rx;
struct dlx_node *ux;
struct dlx_node *dx;
struct dlx_col *colx;
int row_id;
};
struct dlx_col {
struct dlx_node c;
int s;
int id;
};
struct dlx_head {
int col_num;
int row_num;
int size_node;
struct dlx_node h;
struct dlx_col *c;
};
struct location {
int r;
int c;
};
struct dlx_matrix {
int col_num;
int row_num;
int size;
struct location *bitset;
};
void dlx_header_init(struct dlx_head *h, int col_num, int row_num);
void dlx_header_release(struct dlx_head *h);
void dlx_add_node_to_header(struct dlx_head *h, const struct location *loc);
struct dlx_matrix *alloc_matrix_via_str(struct dlx_matrix *matrix,
const char *str, int col_num, int row_num);
void free_matrix(struct dlx_matrix *matrix);
void matrix_to_header(struct dlx_head *h, const struct dlx_matrix *matrix);
struct dlx_col *min_s_col(const struct dlx_head *h);
void dlx_cover_col(struct dlx_col *col);
void dlx_uncover_col(struct dlx_col *col);
int dlx_select_row(struct dlx_node *node);
void dlx_unselect_row(struct dlx_node *node);
int dlx_search(struct dlx_head *h, int *solution, int sel_row_num, int *is_run);
#endif