【注意】邻接表

(1)图论题双向边一般开两倍(有关边的数组);

(2)以图论为例的写法:

void add(int x,int y,int len)
{
 nxt[++tot]=fst[x];
 fst[x]=tot;//tot是指针,不能写成nxt[tot]
 w[tot]=len;
 to[tot]=y;

//双向边要多写这一行以下的
 nxt[++tot]=fst[y];
 fst[y]=tot;
 w[tot]=len;
 to[tot]=x;
}

原文地址:https://www.cnblogs.com/xzs123456/p/10776006.html