邻接表模板

// 邻接表模板
// 头节点,next指针,节点值,结点总数
int h[N], nxt[N],to[N], tot;

void add(int a, int b){
	to[++tot]=b, nxt[tot]=h[a], h[a]=tot; // 先保存节点值 => 头插法 插入链表
}

posted @ 2024-08-11 10:17  Biang-Biang  阅读(3)  评论(0)    收藏  举报