00001
00004 #include <stdlib.h>
00005 #include <stdio.h>
00006 #include <string.h>
00007 #include <math.h>
00008
00009 #define TYP_VARC long
00010 #define TYP_VSOM long
00011 #ifndef HUGE
00012 #define HUGE HUGE_VAL
00013 #endif
00014 #define SHRT_MIN -32767
00015 #define SHRT_MAX +32767
00016 #define USHRT_MAX 65535
00017 #define INT_MIN -32767
00018 #define INT_MAX +32767
00019 #define UINT_MAX 65535
00020 #define LONG_MIN -2147483647
00021 #define LONG_MAX +2147483647
00022 #define ULONG_MAX 4294967295
00023 #define M_PI 3.14159265358979323846
00024 #define max(X,Y) ((X)>=(Y)?(X):(Y))
00025 #define min(X,Y) ((X)<=(Y)?(X):(Y))
00026
00027
00028
00029
00030
00034 typedef struct cell {
00036 int som;
00038 TYP_VARC v_arc;
00040 struct cell * next;
00041 } cell;
00042
00046 typedef cell * pcell;
00047
00048
00052 typedef struct graphe {
00053
00054
00055
00057 int nsom;
00059 int nmaxarc;
00061 int narc;
00062
00063
00064
00066 pcell reserve;
00068 pcell libre;
00070 pcell * gamma;
00071
00072
00073
00074
00076 int *tete;
00078 int *queue;
00079
00080
00081
00083 TYP_VARC *v_arcs;
00084
00085
00086
00088 TYP_VSOM *v_sommets;
00089
00091 double *x;
00093 double *y;
00095 char **nomsommet;
00096 } graphe;
00097
00098
00099
00100
00101
00102 extern void AfficheEnsemble(boolean *s, int n);
00103 extern void AfficheListe(pcell p);
00104 extern void AfficheSuccesseurs(graphe * g) ;
00105 extern void AfficheArcs(graphe * g);
00106 extern void AfficheValeursSommets(graphe * g);
00107 extern void PSGraphe(graphe * g, char *filename, double r, double t, double marge);
00108 void EPSGraphe(graphe * g, char *filename, double r, double t, double marge, int noms_sommets, int v_sommets, int col_sommets, int v_arcs);
00109
00110
00111
00112
00113
00114
00115
00116 extern void AutoNomsSommets(graphe * g, int mode);
00117 extern void PlongementCirculaire(graphe * g, double r);
00118 extern void PlongementRadial(graphe * g, int c);
00119
00120
00121
00122
00123
00124
00125
00126 extern pcell AlloueCell(pcell * plibre);
00127 extern void LibereCell(pcell * plibre, pcell p);
00128 extern void RetireTete(pcell * plibre, pcell * pliste);
00129 extern void AjouteTete(pcell * plibre, pcell * pliste, int a, TYP_VARC v);
00130 extern int EstDansListe(pcell p, int a);
00131
00132
00133
00134
00135
00136
00137
00138 extern graphe * InitGraphe(int nsom, int nmaxarc);
00139 extern void TermineGraphe(graphe * g);
00140 extern graphe * ReadGraphe(char * filename);
00141
00142
00143
00144
00145
00146
00147
00148 extern void AjouteArc(graphe * g, int i, int s);
00149 extern void AjouteArcValue(graphe * g, int i, int s, TYP_VARC v);
00150 extern void RetireArc(graphe * g, int i, int s);
00151 extern int PopSuccesseur(graphe *g, int i);
00152 extern int EstSuccesseur(graphe *g, int i, int s);
00153
00154
00155
00156
00157
00158
00159
00160 extern graphe * GrapheAleatoire(int nsom, int narc);
00161
00162
00163
00164
00165
00166
00167
00168 extern graphe * Symetrique(graphe * g);
00169 extern graphe * FermetureSymetrique(graphe * g);
00170 extern void CompFortConnexe(graphe * g, graphe *g_1, int a, boolean * Ca);
00171 extern boolean ExisteCircuit(graphe * g, int a);
00172 extern void CompConnexe(graphe * g, graphe *g_1, int a, boolean * Ca);
00173 extern boolean Connexe(graphe * g, graphe *g_1);
00174
00175
00176
00177
00178
00179
00180
00181 extern graphe * Kruskal1(graphe * g, graphe *g_1);
00182 extern graphe * Kruskal2(graphe * g, graphe *g_1);
00183
00184
00185
00186
00187
00188
00189
00190 extern void Dijkstra(graphe * g, int i);
00191 extern graphe * PCC(graphe * g, int d, int a);