void convert() // 邻接矩阵转换成邻接表
{
for (int i = 1; i <= n; i ++ )
for (int j = 1; j <= n; j ++ )
if (g[i][j] < INF / 2)
add(i, j, g[i][j]);
}
void convert() // 邻接表转换成邻接矩阵
{
for (int i = 1; i <= n; i ++ )
{
for (auto p = head[i]; p; p = p->next)
{
int j = p->id; // 与i相邻的点的编号
g[i][j] = g[j][i] = p->w;
}
}
}