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

Method dfs4

src/class162/Code03_UnderMoon1.java:151–177  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

149
150 // dfs2的迭代版
151 public static void dfs4() {
152 stacksize = 0;
153 push(1, 1, -1);
154 while (stacksize > 0) {
155 pop();
156 if (edge == -1) {
157 top[first] = second;
158 dfn[first] = ++cntd;
159 if (son[first] == 0) {
160 continue;
161 }
162 push(first, second, -2);
163 push(son[first], second, -1);
164 continue;
165 } else if (edge == -2) {
166 edge = head[first];
167 } else {
168 edge = next[edge];
169 }
170 if (edge != 0) {
171 push(first, second, edge);
172 if (to[edge] != fa[first] && to[edge] != son[first]) {
173 push(to[edge], to[edge], -1);
174 }
175 }
176 }
177 }
178
179 public static void up(int i) {
180 max[i] = Math.max(max[i << 1], max[i << 1 | 1]);

Callers 1

prepareMethod · 0.95

Calls 2

pushMethod · 0.95
popMethod · 0.95

Tested by

no test coverage detected