以任意一点/奇数度点开始dfs,能走就走,遍历所有边,离开时加入点。
void dfs(int x) {
for(; t[x]<G[x].size(); ) {
int y=G[x][t[x]]; ++t[x];
dfs(y);
}
z.push(x);
}
以任意一点/奇数度点开始dfs,能走就走,遍历所有边,离开时加入点。
void dfs(int x) {
for(; t[x]<G[x].size(); ) {
int y=G[x][t[x]]; ++t[x];
dfs(y);
}
z.push(x);
}