Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marian POIROT
Our awesome project
Commits
52010a1b
Commit
52010a1b
authored
Jun 24, 2021
by
Valentin MEUNIER
Browse files
le
parent
a5b58682
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
laby/Aetoile.c
View file @
52010a1b
...
...
@@ -10,7 +10,7 @@ int max(int a, int b)
int
distance_euclidienne
(
int
a
,
int
b
)
{
return
(
int
)
sqrt
((
a
/
P
-
b
/
b
)
*
(
a
/
P
-
b
/
P
)
+
(
a
%
P
-
b
%
P
)
*
(
a
%
P
-
b
%
P
));
return
(
int
)
sqrt
((
a
/
P
-
b
/
P
)
*
(
a
/
P
-
b
/
P
)
+
(
a
%
P
-
b
%
P
)
*
(
a
%
P
-
b
%
P
));
}
int
distance_tcheby
(
int
a
,
int
b
)
...
...
@@ -79,6 +79,7 @@ int * dijsktra(int ** laby, int noeuds, int depart)
if
(
distance
[
voisin
[
j
]].
poids
>
1
+
distance
[
sommet
].
poids
)
{
distance
[
voisin
[
j
]].
poids
=
1
+
distance
[
sommet
].
poids
;
tas
->
tab
[
indice_valeur
[
voisin
[
j
]]].
poids
=
distance
[
voisin
[
j
]].
poids
;
percolation_bas_tas_min
(
tas
,
indice_valeur
[
voisin
[
j
]],
indice_valeur
);
parent
[
voisin
[
j
]]
=
sommet
;
}
...
...
@@ -162,6 +163,7 @@ int * Aetoile_euclidienne(int ** laby, int noeuds, int depart, int arrivee)
if
(
distance
[
voisin
[
j
]].
poids
>
(
1
+
distance
[
sommet
].
poids
+
distance_euclidienne
(
voisin
[
j
],
arrivee
)))
{
distance
[
voisin
[
j
]].
poids
=
1
+
distance
[
sommet
].
poids
+
distance_euclidienne
(
voisin
[
j
],
arrivee
);
tas
->
tab
[
indice_valeur
[
voisin
[
j
]]].
poids
=
distance
[
voisin
[
j
]].
poids
;
percolation_bas_tas_min
(
tas
,
indice_valeur
[
voisin
[
j
]],
indice_valeur
);
parent
[
voisin
[
j
]]
=
sommet
;
}
...
...
@@ -246,6 +248,7 @@ int * Aetoile_tcheby(int ** laby, int noeuds, int depart,int arrivee)
if
(
distance
[
voisin
[
j
]].
poids
>
1
+
distance
[
sommet
].
poids
+
distance_tcheby
(
voisin
[
j
],
arrivee
))
{
distance
[
voisin
[
j
]].
poids
=
1
+
distance
[
sommet
].
poids
+
distance_tcheby
(
voisin
[
j
],
arrivee
);
tas
->
tab
[
indice_valeur
[
voisin
[
j
]]].
poids
=
distance
[
voisin
[
j
]].
poids
;
percolation_bas_tas_min
(
tas
,
indice_valeur
[
voisin
[
j
]],
indice_valeur
);
parent
[
voisin
[
j
]]
=
sommet
;
}
...
...
@@ -330,6 +333,7 @@ int * Aetoile_manhattan(int ** laby, int noeuds, int depart, int arrivee)
if
(
distance
[
voisin
[
j
]].
poids
>
1
+
distance
[
sommet
].
poids
+
distance_manhattan
(
voisin
[
j
],
arrivee
))
{
distance
[
voisin
[
j
]].
poids
=
1
+
distance
[
sommet
].
poids
+
distance_manhattan
(
voisin
[
j
],
arrivee
);
tas
->
tab
[
indice_valeur
[
voisin
[
j
]]].
poids
=
distance
[
voisin
[
j
]].
poids
;
percolation_bas_tas_min
(
tas
,
indice_valeur
[
voisin
[
j
]],
indice_valeur
);
parent
[
voisin
[
j
]]
=
sommet
;
}
...
...
@@ -376,39 +380,41 @@ int main (int argc, char** argv)
graph
=
kruskal
(
graph
,
noeuds
,
nb_aretes
,
&
cours
,
p
);
tab
=
tableau_ligne
(
graph
,
cours
);
affiche_graph_couple
(
gr
int
depart
=
rand
()
%
noeuds
;
int
arrivee
=
rand
()
%
noeuds
;
clock_t
t_depart
,
t_fin
;
f
lo
at
temps
;
lo
ng
temps
;
t_depart
=
clock
();
// for (int i=0; i<1000; i++)
parent
=
dijsktra
(
tab
,
noeuds
,
arrivee
);
t_fin
=
clock
();
temps
=-
t_depart
+
t_fin
;
printf
(
"temps dijsktra : %
f
\n
"
,
temps
);
printf
(
"temps dijsktra : %
ld
\n
"
,
temps
);
t_depart
=
clock
();
// for (int i=0; i<1000; i++)
parent
=
Aetoile_euclidienne
(
tab
,
noeuds
,
depart
,
arrivee
);
t_fin
=
clock
();
temps
=-
t_depart
+
t_fin
;
printf
(
"temps Aetoile_euclidienne : %
f
\n
"
,
temps
);
printf
(
"temps Aetoile_euclidienne : %
ld
\n
"
,
temps
);
t_depart
=
clock
();
// for (int i=0; i<1000; i++)
parent
=
Aetoile_tcheby
(
tab
,
noeuds
,
depart
,
arrivee
);
t_fin
=
clock
();
temps
=-
t_depart
+
t_fin
;
printf
(
"temps Aetoile_tcheby : %
f
\n
"
,
temps
);
printf
(
"temps Aetoile_tcheby : %
ld
\n
"
,
temps
);
t_depart
=
clock
();
// for (int i=0; i<1000; i++)
parent
=
Aetoile_manhattan
(
tab
,
noeuds
,
depart
,
arrivee
);
t_fin
=
clock
();
temps
=-
t_depart
+
t_fin
;
printf
(
"temps Aetoile_manhattan: %
f
\n
"
,
temps
);
printf
(
"temps Aetoile_manhattan: %
ld
\n
"
,
temps
);
}
laby/affichage_image.c
View file @
52010a1b
...
...
@@ -178,3 +178,10 @@ void afficherImage(SDL_Renderer *renderer,SDL_Window *window,int **tab,int taill
}
}
void
peindreMap
(
SDL_Texture
*
texture
,
SDL_Window
*
window
,
SDL_Renderer
*
renderer
,
int
noeuds
,
int
taille_cell
,
int
**
laby
)
{
printf
(
"peindre case %d %d %d
\n
"
,
noeuds
%
P
,
noeuds
/
P
,
laby
[
noeuds
%
P
][
noeuds
/
P
]);
affichage_texture
(
texture
,
window
,
renderer
,
laby
[
noeuds
%
P
][
noeuds
/
P
],
noeuds
%
P
,
noeuds
/
P
,
taille_cell
);
}
laby/affichage_image.h
View file @
52010a1b
...
...
@@ -5,5 +5,6 @@ SDL_Texture* load_texture_from_image(char * file_image_name, SDL_Renderer *ren
void
affichage_texture
(
SDL_Texture
*
my_texture
,
SDL_Window
*
window
,
SDL_Renderer
*
renderer
,
int
x
,
int
coord_colonne
,
int
coord_ligne
,
int
taille_cell
);
void
afficherImage
(
SDL_Renderer
*
renderer
,
SDL_Window
*
window
,
int
**
tab
,
int
taille_cell
,
SDL_Texture
*
texture
);
void
affichage_fin
(
SDL_Texture
*
my_texture
,
SDL_Window
*
window
,
SDL_Renderer
*
renderer
,
int
coord_colonne
,
int
coord_ligne
,
int
taille_cell
);
void
peindreMap
(
SDL_Texture
*
texture
,
SDL_Window
*
window
,
SDL_Renderer
*
renderer
,
int
noeuds
,
int
taille_cell
,
int
**
laby
);
#endif
laby/kruskal.h
View file @
52010a1b
...
...
@@ -4,8 +4,8 @@
#include "tas.h"
#include "graph_aretes_tab.h"
#define N
1
3
#define P
1
5
#define N
9
3
#define P
9
5
graph_t
*
kruskal
(
graph_t
*
graph
,
int
noeuds
,
int
nb_aretes
,
int
*
cours
,
double
p
);
...
...
laby/main.c
View file @
52010a1b
This diff is collapsed.
Click to expand it.
laby/main.h
View file @
52010a1b
...
...
@@ -6,24 +6,25 @@
#include<SDL2/SDL.h>
#include "kruskal.h"
#include <math.h>
#include "affichage_image.h"
#include "dijsktra.h"
#include "texture_perso.h"
#include "colision.h"
#include "DFS.h"
#include "affichage_image.h"
#include <math.h>
typedef
enum
{
FLAG_N
=
1
,
FLAG_S
=
2
,
FLAG_E
=
4
,
FLAG_O
=
8
}
flag_t
;
void
end_sdl
(
char
ok
,
char
const
*
msg
,
SDL_Window
*
window
,
SDL_Renderer
*
renderer
);
void
afficheEcranIntelligement
(
SDL_Renderer
*
,
int
**
,
int
);
void
chemin
(
SDL_Renderer
*
,
int
,
int
,
int
,
int
*
);
void
peindreDFS
(
SDL_Renderer
*
,
int
,
int
);
int
min
(
int
,
int
);
int
main
(
int
,
char
**
);
typedef
enum
{
FLAG_N
=
1
,
FLAG_S
=
2
,
FLAG_E
=
4
,
FLAG_O
=
8
}
flag_t
;
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment