-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaffiche.c
More file actions
114 lines (95 loc) · 3.12 KB
/
affiche.c
File metadata and controls
114 lines (95 loc) · 3.12 KB
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
/******************************************************************/
/** **/
/** AFFICHE.C **/
/** **/
/******************************************************************/
#include "graph.h"
// Affiche un message d'aide ------------------------------------------------
void AfficheAide(void)
{
printf( "[Graph] Résolution des graphs -----------------------" );
printf( "\nUsage: graph [OPTIONS] -f file.txt" );
printf( "\n\t-f foo.txt : charge le graph du fichier foo.txt" );
printf( "\n\t-x : export result in \'foo.res\' file" );
printf( "\n\t-v : mode verbose, bavard" );
printf( "\n\t-V : mode verbose encore plus, bavard encore plus" );
printf( "\n\t-c : charge aussi les consos courantes" );
printf( "\n\t-l : parcour le graph en largeur" );
printf( "\n\t-p : OU parcour le graph en proffondeur" );
printf( "\n\t-h : ce message d'aide" );
printf( "\n" );
}
// Affiche le resultat du flot total max --------------------------------------
void AfficheTotal(void)
{
int i ;
float Total = 0 ;
for (i = 0; i < NBR_SOMMET; i++)
Total += Matrice_Conso[0][i];
CYAN
printf("\nFlot total : %.2f\n\n", Total);
DEFAULT_COLOR
}
// ----------------------------------------------------------------------------
// Affiche la matrice des flots / capacités -----------------------------------
// ----------------------------------------------------------------------------
void AfficheConso(void)
{
int i, j ;
GREEN printf ( "\n" );
for (i = 0; i < NBR_SOMMET; i++)
printf ( " %3s ", NomSommet[ i ] );
DEFAULT_COLOR printf("\n");
for (i = 0; i < NBR_SOMMET; i++) {
// Affiche la ligne
for (j = 0; j < NBR_SOMMET; j++ ) {
printf ( "\033[0;33m" );
if (Matrice_Max[i][j]) {
if (Matrice_Conso[i][j] == Matrice_Max[i][j])
printf ("\033[1;33m");
printf(" %2.0f/%2.0f ", Matrice_Conso[i][j], Matrice_Max[i][j]);
} else
printf(" ----- ");
}
GREEN printf(" %3s\n", (NomSommet[i])); DEFAULT_COLOR
}
}
// Affiche les elements de la liste ----------------------------------------------
void AfficheListe(struct Chainon *L)
{
printf("\n\t-> Liste des sommets à faire : \033[0;32m");
while (L) {
printf(" %s ", NomSommet[L->Sommet]);
L = L->suiv;
}
DEFAULT_COLOR
}
// Retrouve le parcour ------------------------------------------------------------
void AfficheParcour(int OPTIONS)
{
int i = NBR_SOMMET - 1;
if (Sommet[i] == -1)
printf("\n\tChaine trouvée : aucune");
else
printf("\n\tChaine trouvée : ");
while ((Sommet[i] != -1) && (i != 0)) {
if (Matrice_Max[Sommet[i]][i]) {
printf("\t %d:%s(%2.0f)", i, NomSommet[i], Matrice_Max[Sommet[i]][i] - Matrice_Conso[Sommet[i]][i]);
} else {
printf("\t %d:%s", i, NomSommet[i]);
RED
printf("(%2.0f)", Matrice_Conso[i][Sommet[i]]);
DEFAULT_COLOR
}
i = Sommet[i];
}
if (!(OPTIONS & G_VERB))
return;
printf("\n\tSommets marqués : ");
for (i = 0; i < NBR_SOMMET; i++) {
if (Sommet[i] != -1)
printf("\t %s:%s", NomSommet[i], NomSommet[Sommet[i]]);
else
printf("\t %s:--", NomSommet[i]);
}
}