MCPcopy Create free account
hub / github.com/algorithmzuo/algorithm-journey / dfs2

Method dfs2

src/class184/Code01_Capital1.java:161–183  ·  view source on GitHub ↗
(int cur, int fa, int root)

Source from the content-addressed store, hash-verified

159
160 // 收集信息迭代版
161 public static void dfs2(int cur, int fa, int root) {
162 stacksize = 0;
163 push(cur, fa, root, -1);
164 while (stacksize > 0) {
165 pop();
166 if (e == -1) {
167 father[u] = f;
168 nodeRoot[u] = rt;
169 nodeVis[u] = false;
170 colorVis[color[u]] = false;
171 e = headg[u];
172 } else {
173 e = nextg[e];
174 }
175 if (e != 0) {
176 push(u, f, rt, e);
177 int v = tog[e];
178 if (v != f && !vis[v]) {
179 push(v, u, rt, -1);
180 }
181 }
182 }
183 }
184
185 public static int calc(int u) {
186 // dfs1(u, 0, u);

Callers 1

calcMethod · 0.95

Calls 2

pushMethod · 0.95
popMethod · 0.95

Tested by

no test coverage detected