*   >> Lectura Educación Artículos >> science >> programación

Dijkstra & amp; rsquo; s Algorithm

: ");

scanf ("% d ", & N );

printf ("\\ nNo la matriz de longitud de la gráfica: \\ n");

for (i = 0; i

for (j = 0; j

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

/* INITIALIZATION * /

for (i = 0; i

v [i] = 65 + i;

'A'

v0 =;

de estado [0] = '';

dist [0] = 0;

siguiente [0] = '*';

for (i = 1; i

{

Estado [i] = '? ';

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

siguiente [i] = v0;

}

/* PROCESAMIENTO * /

for (j = 0; j

{

//IMPRESIÓN

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", el estado de [i]);

printf ("\\ NDIST |");

for (i = 0; i

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

printf ("\\ Nnext |");

for (i = 0; i

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

/* PROCESO * /

si (j

{

for (i = 1; '?' i

si (estado [i] ==)

{

min = dist [i];

r = i;

romper;

}

for (i = 0; i

si (estado [i] == && dist [i]

{

min = dist [i] '?';

r = i;

}

v1 = v [r];

Estado de [r] = '';

for (i = 0; i

{

si (estado [i] == '?' && dist [i]> (dist [r] + a [r] [i]))

{

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

siguiente [i] = v1;

}

}

getch ();

}

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

}

printf (" \\ n \\ nLa bordes incluido en el árbol Spaning son: - \\ n \\ n ");

for (i = 1; i

printf ("% c% c ", al lado [ ,,,0],i], 65 + i);

printf ("\\ n \\ n ** PESO DEL ÁRBOL spaning MÍNIMO ES =");

for (i = 1; i

< p> {

for (j = 0; j

{

si (al lado [i] == v [j])

{

si (i == n-1)

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

cosa

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

s = s + a [j] [i];

romper;

}

}

}

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

getch ();

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

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

{

printf ("n \\ \\ t \\ t% c ->% c =% c ->% c", v [i], v0, v [i], al lado [i]);

Page   <<  [1] [2] [3] [4] >>
Copyright © 2008 - 2016 Lectura Educación Artículos,https://lectura.nmjjxx.com All rights reserved.