链式前项星(模板)
struct edg{int next,to,wi;//next表示下一條邊的編號,to表示當前邊的終點,wi表示當前邊的權值
}s[maxn*2];
int head[maxn];//如;head[a]表示以a為起點的第一條邊的編號,初始值為-1
int cnt=0;
void add(int u,int v,int w){//加邊s[cnt].to=v;s[cnt].wi=w;s[cnt].next=head[u];head[u]=cnt++;
}
int u=be;//遍歷以u為起點的所有邊
for(int i=head[u];i!=-1;i=s[i].next)
?
??
轉載于:https://www.cnblogs.com/Zhi-71/p/10022572.html
總結
- 上一篇: C# in Depth-类型系统的特征
- 下一篇: SQLSERVER 和 ORACLE 查