其实,这个东西,只要明白链式前方有星星,就应该都想出来了。 如果你还不理解链式前星,那就先学习吧。
结构边缘{ int fr,to,top,bot; //fr为起点,to为终点,top为边缘集堆栈该边以上的边,bot为边缘集堆栈该边以下的边}e[2000005]; int head[2005],ecnt=0; inlinevoidadd_edge(intu,int v ) {e[ ecnt].fr=u; //编辑起点e[ecnt].to=v; //编辑终点e[ecnt].top=0; //新添加的边是堆栈顶,因此上面不存在边,0 e[head[u]].top=ecnt; //原始堆栈顶部是其边e[ecnt].bot=head[u]; //其边下为原堆栈顶head[u]=ecnt; //新堆栈的山顶是这一带的返回; }inlinevoiddelete_edge(intnow ) {//now是要删除的边的编号int up=e[now].top,down=e[now].bot; if(up==0) head[e[now].fr]=down; //更改堆栈顶部elsee[up].bot=down; //上边下if(down0) e[down].top=up; //在下边上改变返回; }