这是最主要的存图模式,代码好写,时间复杂度O(E)。
懒人会直接使用vector代替链式前向星。。。
不好理解啊,我也是听了好几遍才明白一点。。。
const int N=10005;
const int M=100005;
int head[N];
int nex[M];
int to[M];
int ce;
void add(int,int);
int n;
int m;
void add(int u,int v)
{
to[++ce]=v;
nex[ce]=head[u];
head[u]=ce;
in[v]++;
}
这是一部分,实在想不出写点啥完整的。。。