链式前向星
David_Liu
2018-10-14 11:57:58
今天呢,本蒟蒻在沐浴Bei-S的清化时,顺带复习了一下尘封多年的图论的一些基础操作。
本篇博呢,主要在于给大家分享一下链式前向星的基础操作,和图的结构体的封装操作。
不多说先上基础操作的代码:
```cpp
struct edge{
int to, w, nxt;
}e[M<<1];
int head[M], tot;
inline void add(int u, int v, int w){
e[++cnt].nxt = head[u];
e[cnt].to = v;
e[cnt].w = w;
head[u] = ++tot;
}
inline void adde(int u, int v, int w) {
add(u, v, w);
add(v, u, w);
}
```
未完待续。。