#include<iostream>
using namespace std;
#define MaxVerterNum 100
typedef char VerterType;
typedef int EdgeType;
typedef struct
{
VerterType vexs[MaxVerterNum];
EdgeType edges[MaxVerterNum][MaxVerterNum];
int n, e;
}MGraph;
void createMGraph(MGraph* G)
{
std::cin >> G->n >> G->e;
for (int i = 0; i < G->n; ++i)
{
std::cin >> G->vexs[i];
}
for (int i = 0; i < G->n; ++i)
{
for (int j = 0; j < G->n; ++j)
{
G->edges[i][j] = 0;
}
}
int i, j;
for (int k = 0; k < G->e; ++k)
{
std::cin >> i >> j;
G->edges[i][j] = 1;
G->edges[j][i] = 1;
}
}
int main()
{
MGraph* pg = new MGraph;
createMGraph(pg);
for (int i = 0; i < pg->n; ++i)
{
for (int j = 0; j < pg->n; ++j)
{
std::cout << pg->edges[i][j] << "\t";
}
std::cout << endl;
}
delete pg;
return 0;
}
输入
输出