邻接矩阵
作者:互联网
const int maxvex = 100;
const int INF = 65535;
struct graph {
int v[maxvex];
int arc[maxvex][maxvex];
int numv, nume;
};
void create(graph* G) {
int i, j, k, w;
cin >> G->numv >> G->nume;
for (int i = 0; i < G->numv; i++) {
cin >> G->v[i];
}
for (int i = 0; i < G->numv; i++) {
for (int j = 0; j < G->numv; j++)
G->arc[i][j] = INF;
}
for (int k = 0; k < G->nume; k++) {
cin >> i >> j >> w;
G->arc[i][j] = w;
G->arc[j][i] = G->arc[i][j];
}
}
标签:numv,int,maxvex,cin,邻接矩阵,++,arc 来源: https://www.cnblogs.com/wxy214/p/16485957.html