-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTypGraphe.h
163 lines (143 loc) · 4.03 KB
/
TypGraphe.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
* File: TypGraphe.h
* Author: maxime & awaleh
*
* Created on 24 octobre 2014, 20:50
*/
#pragma once
#include "TypVoisin.h"
#ifdef __cplusplus
extern "C"
{
#endif
/**
* La structure TypGraphe
*/
typedef struct
{
bool estOriente : 1;
int nbMaxSommets;
TypVoisins** listesAdjacences;
} TypGraphe;
typedef int errorcode;
/**
* chaines des caracteres correspondant aux erreurs renvoyées par les fonctions
* ci dessous.
*/
static const char* TYPGRAPH_ERRORS[] = {
"wtf (What a Terrible Failure)",
"impossible d'acceder au sommet",
"le sommet existe deja",
"le sommet n'existe pas",
"erreur lors de la creation de l'arrete",
"il existe deja une arrete allant vers ce sommet",
"l'arrete n'existe pas",
"erreur lors de la suppression de l'arrete",
"impossible d'ouvrir le fichier"
};
/**
* Crée un nouveau graph.
* @param nbMaxSommets le nombre maximum de sommets
* @param estOriente si le graph est oriente ou pas
* @return un graph malloced.
*/
TypGraphe* newTypGraphe(int nbMaxSommets, bool estOriente);
/**
* Verification d'un acces a une liste d'adjacences
* @param self le graph
* @param i le sommet cible
* @return un boolean
*/
bool checkAccessListesAdjacences(TypGraphe* self, voisinT i);
/**
* Verification de l'existance d'un sommet.
* @param self le graph
* @param i le sommet cible
* @return un boolean
*/
bool checkSommetExist(TypGraphe* self, voisinT i);
/**
* insertion d'un sommet dans un graph
* @param self le graph
* @param numero le sommet cible
* @return une erreur si < 0
*/
errorcode insertionSommetTypGraphe(TypGraphe* self, voisinT numero);
/**
* la fonction qui insert réelement une arrete dans un graph.
* @param self le graph
* @param from le sommet de depart
* @param to le sommet d'arrivé
* @param data la donnée
* @return le nouvel element de la liste chainé ou null si erreur.
*/
static TypVoisins* _insertionAreteTypGraphe(TypGraphe* self, voisinT from,
voisinT to, dataT data);
/**
* permet de savoir si le sommet est adjacent a un autre.
* @param self le graph
* @param from le sommet de depart
* @param to le sommet d'arrivé
* @return l'element de la liste chainé qui definit le lien ou null pas de lien
*/
TypVoisins* getSommetAdjacentTypGraphe(TypGraphe* self, voisinT from, voisinT to);
/**
* insertion d'une nouvelle arrete dans un graph.
* @param self le graph
* @param from le sommet de depart
* @param to le sommet d'arrivé
* @param data la donnée
* @return une erreur si < 0
*/
errorcode insertionAreteTypGraphe(TypGraphe* self, voisinT from, voisinT to, dataT data);
/**
* insertion d'un chemin bidirectionnel entre deux sommet.
* @param self le graph
* @param from le sommet de depart
* @param to le sommet d'arrivé
* @param data la donnée
* @return une erreur si < 0
*/
errorcode insertionSymetriqueAreteTypGraphe(TypGraphe* self, voisinT from, voisinT to, dataT data);
/**
* la fonction qui supprime réelement une arrete d'un graph
* @param self le graph
* @param from le sommet de depart
* @param to le sommet d'arrivé
* @return une erreur si < 0
*/
errorcode _suppressionAreteTypGraphe(TypGraphe* self, voisinT from, voisinT to);
/**
* supprime une arrete dans un graph
* @param self le graph
* @param from le sommet de depart
* @param to le sommet d'arrivé
* @return une erreur si < 0
*/
errorcode suppressionAreteTypGraphe(TypGraphe* self, voisinT from, voisinT to);
/**
* supprime un sommet d'un graph
* @param self le graph
* @param sommet le sommet a supprimer
* @return une erreur si < 0
*/
errorcode suppressionSommetTypGraphe(TypGraphe* self, voisinT sommet);
/**
* Sauvegarde le graph dans un format specifié
* @param g le graph
* @param fichier le fichier où sauvegarder
*/
void sauvegardeTypGraphe(TypGraphe* g, FILE* fichier);
/**
* Affichage d'un graph sur la sortie standard
* @param g le graph
*/
void affichageTypGraphe(TypGraphe* g);
/**
* Suppression du graph
* @param self
*/
void deleteTypGraphe(TypGraphe* self);
#ifdef __cplusplus
}
#endif