Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dsprog
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Manuel Bucher
dsprog
Commits
f764b3fb
Commit
f764b3fb
authored
6 years ago
by
Manuel Bucher
Browse files
Options
Downloads
Patches
Plain Diff
Passed check, with rearranged neighbours
parent
6b5954d0
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
loesung.c
+13
-8
13 additions, 8 deletions
loesung.c
with
13 additions
and
8 deletions
loesung.c
+
13
−
8
View file @
f764b3fb
...
...
@@ -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
(
u
int
32_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
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment