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

链式前向星

这个博客写的不错: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)

 

posted @   Wisdom+.+  阅读(137)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示