使用链式前向星储存边后,在某些dfs的情况下,需要判断是不是向下搜索时的边
那么下面这段代码其背后的原理是什么呢?
inline void add(int u,int v,int w)
{
ver[tot] = v;
edge[tot] = w;
nex[tot] = head[u];
head[u] = tot ++;
}
memset(head, -1, sizeof head);
void dfs(int x,int last_edge)
{
if (vis[x])
{
return;
}
vis[x] = 1;
for (int i = head[x];~i;i = nex[i])
{
int y = ver[i];
if (i != ((in_edge) ^ 1))
{
}
}
return 0;
}