跳到正文

个人记录

图的一些板子

Chen_Three约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年2月10日
收录
2025年12月12日
更新
2026年11月14日
篇幅
约 1 分钟

版本

  1. v1当前

链式前向星

C++
struct graph{
	struct node{
		ll from, to, dis, next;
	}edge[M << 1];
	ll t, head[N];
	inline void clear(){
		memset(head, 0, sizeof(head));
		t = 0;
	}
	inline void add_edge(ll u, ll v, ll w){
		edge[++t] = (node){u, v, w, head[u]};
		head[u] = t;
	}
}G;
原文