*   >> Lecture Éducation Articles >> science >> la programmation

Dijkstra & amp; rsquo; Algorithm

de sommets: ");

scanf ("% d ", et n );

printf ("\\ nEntrez la matrice de la longueur du graphique: \\ n");

for (i = 0; i

pour (j = 0; j

scanf ("% d", et a [i] [j]);

/* * INITIALISATION /

for (i = 0; i

v [i] = 65 + i;

v0 = 'A';

statut [0] = '';

dist [0] = 0;

suivante [0] = '*';

for (i = 1; i

{

statut [i] = '? ';

dist [i] = a [i] [0];

suivante [i] = v0;

}

/* TRAITEMENT * /

pour (j = 0; j

{

//IMPRESSION

printf ("\\ NVERTEX | ");

for (i = 0; i

printf ("% c \\ t ", v [i]);

printf (" \\ n ") ;

for (i = 0; i

printf ("---------");

printf ("\\ nstatus |");

for (i = 0; i

printf ("% c \\ t", le statut [i]);

printf ("\\ NDist |");

for (i = 0; i

printf ("% d \\ t", dist [i]);

printf ("\\ Nnext |");

for (i = 0; i

printf ("% c \\ t", à côté [i]);

/* PROCESSUS * /

si (j

{

for (i = 1; '?' i

Si (état [i] ==)

{

min = dist [i];

r = i;

briser;

}

for (i = 0; i

Si (état [i] == && dist [i]

{

min = dist [i] '?';

r = i;

}

v1 = v [r];

statut [r] = '';

for (i = 0; i

{

Si (état [i] == '?' && dist [i]> (dist [r] + un [r] [i]))

{

dist [i] = dist [r] + un [r] [i];

suivante [i] = v1;

}

}

getch ();

}

printf ("\\ n \\ n");

}

printf (" \\ n \\ nLe bords inclus dans l'arbre de spaning sont: - \\ n \\ n ");

for (i = 1; i

printf ("% c% c ", à côté [ ,,,0],i], 65 + i);

printf ("\\ n \\ n ** DE POIDS MINIMAL SPANING arbre est =");

for (i = 1; i

< p> {

pour (j = 0; j

{

Si (à côté [i] == v [j])

{

if (i == n-1)

printf ("% d", un [j] [i]);

autre

printf ("% d +", un [j] [i]);

= Les s de + un [j] [i];

briser;

}

}

}

printf ("\\ n \\ t \\ t \\ t \\ t =% d", s);

getch ();

printf ("\\ n \\ nSHORTEST DISTANCE DE \\ n");

for (i = n-1; i> 0; i--)

{

printf ("\\ n \\ t \\ t% c ->% c =% c ->% c", v [i], v0, v [i], la pro

Page   <<  [1] [2] [3] [4] >>
Copyright © 2008 - 2016 Lecture Éducation Articles,https://lecture.nmjjxx.com All rights reserved.