Inputnya
:
#include
<iostream>
#include
<conio.h>
using
namespace std;
void
floyds(int b[][7])
{
int i, j, k;
for (k = 0; k < 7; k++)
{
for (i = 0; i < 7; i++)
{
for (j = 0; j < 7; j++)
{
if ((b[i][k] * b[k][j] != 0) && (i != j))
{
if ((b[i][k] + b[k][j] < b[i][j]) || (b[i][j] == 0))
{
b[i][j] = b[i][k] + b[k][j];
}
}
}
}
}
for (i = 0; i < 7; i++)
{
cout<<"\nMinimum Cost With Respect to
Node:"<<i<<endl;
for (j = 0; j < 7; j++)
{
cout<<b[i][j]<<"\t";
}
}
}
int
main()
{
int b[7][7];
cout<<"MASUKKAN NILAI ADJACENCY MATRIX NYA\n\n";
for (int i = 0; i < 7; i++)
{
cout<<"masukkan nilai untuk "<<(i+1)<<"
garis"<<endl;
for (int j = 0; j < 7; j++)
{
cin>>b[i][j];
}
}
floyds(b);
getch();
}
Output
nya :
IMPLEMENTASI BAHASA PEMROGRAMAN C++ PADA ALGORITMA GRAF FLOYD-MARSHALL
Reviewed by Wid Arfian
on
November 17, 2019
Rating:
Tidak ada komentar: