Matricea lanturilor
of 1
/1
-
Upload
mihaela-manole -
Category
Documents
-
view
339 -
download
18
Embed Size (px)
description
Matricea lanturilor - grafuri
Transcript of Matricea lanturilor
Matricea lanturilor - algoritmul Roy-WarshallSe citeste un graf neorientat cu n noduri si m muchii dat prin vectorul muchiilor. Sa se construiasca o matricea existentei lanturilor(a[i][j] este 1 daca exista lant de la i la j si 0 in caz contrar).Ex: Pentru graful din imagine se obtine matricea lanturilor urmatoare:0 0 1 1 1 10 0 0 0 0 01 0 0 1 1 11 0 1 0 1 11 0 1 1 0 11 0 1 1 1 0
#includeint k,m,n,x[100],a[100][100],p[100];
fstream f("graf.in",ios::in);fstream g("graf.out",ios::out);
void citire() {int x,y; f>>n>>m; for(int i=1;i>x>>y; a[x][y]=1; a[y][x]=1; } }void rw() {int i, j, k; for(k=1;k