算法笔记--图的存储之链式前向星

链式前向星

这个博客写的不错:http://blog.csdn.net/acdreamers/article/details/16902023

模板:

①add_edge

void add_edge(int u,int v,int w)
{
        edge[cnt].to=v;
        edge[cnt].w=w;
        edge[cnt].next=head[u];
        head[u]=cnt++;
}

②遍历以u节点为起点的所有边

for(int i=head[u];~i;i=edge[i].next)
原文地址:https://www.cnblogs.com/widsom/p/7637359.html