The main idea, give the N nodes, M-edge, each edge of the weight of the line from the edge of the police are not caught by the probability, asked from Node A to Node B is not caught the maximum probability.
Floyd deformation, simply change the equation to max[I [j] =max (max[i] [j], max[I [k]*max[K] [j]), the initial time max[I [j] = 0, there is also a point worth noting is the weight of the edge of the topic (i.e. Probability) is between 1 and 100, and the direct multiplication can be hyperspace, so the storage is divided by 100.
#include <stdio.h>
double max[110][110];
int n,m;
void Floyd ()
{
int i,j,k;
for (k=1;k<=n;k++) for (
i=1;i<=n;i++) for (
j=1;j<=n;j++)
if (Max[i][j]<max[i][k]*max[k][j] )
max[i][j]=max[i][k]*max[k][j];
}
int main ()
{
int i,j,a,b,k;
Double p;
while (1)
{
scanf ("%d%d", &n,&m);
if (n==0) break
;
for (i=1;i<=n;i++) for
(j=1;j<=n;j++)
max[i][j]=0;
for (k=1;k<=m;k++)
{
scanf ("%d%d%lf", &a,&b,&p);
max[a][b]=max[b][a]=p/100;
}
Floyd ();
max[1][n]*=100;
printf ("%.6lf percent\n", Max[1][n]);
}
return 0;
}