Skip to content
Snippets Groups Projects
Commit f764b3fb authored by Manuel Bucher's avatar Manuel Bucher
Browse files

Passed check, with rearranged neighbours

parent 6b5954d0
No related merge requests found
......@@ -185,14 +185,14 @@ int field_neighbours(Field *this) {
return 1; // Doppelung
} else if (t[cur].y-1 == t[east].y) {
t[cur].neigh[1] = east;
t[east].neigh[3] = cur;
t[east].neigh[2] = cur;
}
} else {
top = begin_line;
begin_line = cur; // neue Zeile
}
// ermitteln der Zeilen-Beziehung
if (t[begin_line].x != 0 && t[top].x < t[begin_line].x - 1) {
if (begin_line != 1 && t[top].x < t[begin_line].x - 1) {
// Zeilensprung => Warten bis zur naechsten Zeile angekommen
} else if (t[top].x == t[cur].x - 1) {
// finden, ob paar nach oben existiert O(n) fuer alle Nachbarn nach oben/unten.
......@@ -201,7 +201,7 @@ int field_neighbours(Field *this) {
// aktuelle obere Kachel koennte benachbart sein
if (t[top].y == t[cur].y) { // nicht auf naechste Zeile uebergegangen
// Neue Verbindung oben/unten gefunden
t[top].neigh[2] = cur;
t[top].neigh[3] = cur;
t[cur].neigh[0] = top;
}
}
......@@ -264,7 +264,7 @@ bool hk_bfs(Field *this) {
Queue q; // Schlange von Kacheln
queue_init(&q);
Tile *t = this->tiles;
for (int i = 1; i < this->num_tiles; i++) {
for (uint32_t i = 1; i < this->num_tiles; i++) {
// nur gerade Kacheln werden zur queue hinzufuegen
if (tile_odd(&t[i])) {
continue;
......@@ -318,15 +318,16 @@ bool hk_dfs(Field *this, uint32_t e) {
void hk_print(Field *this) {
Tile *t = this->tiles;
for (uint32_t i = 1; i < this->num_tiles; i++) {
//printf("%u\n", i);
/*for (uint32_t i = 1; i < this->num_tiles; i++) {
uint32_t p = t[i].pair;
printf("%u: %u %u;%u %u\n", i, t[i].x, t[i].y, t[p].x, t[p].y);
if (this->tiles[i].pair == 0) {
printf("None\n");
return;
}
}
}*/
for (uint32_t i = 1; i < this->num_tiles; i++) {
if (tile_odd(&t[i]))
if (!tile_odd(&t[i]))
continue;
uint32_t p = t[i].pair;
printf("%u %u;%u %u\n", t[i].x, t[i].y, t[p].x, t[p].y);
......@@ -360,8 +361,12 @@ int main() {
fprintf(stderr, "Error: Duplicated entry\n"); // Duplikat exisitert
break;
}
//field_print(&f);
if (f.num_tiles - f.num_odd == f.num_odd) {
printf("None\n");
fprintf(stderr, "Ungleiche Knotenbelegung");
break;
}
hk(&f); // Algorithmus von Hopcroft und Karp
result = EXIT_SUCCESS;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment