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

Method dfs2

src/class183/Code06_Maschera1.java:184–207  ·  view source on GitHub ↗
(int cur, int fa, int pmaxv, int pedge)

Source from the content-addressed store, hash-verified

182
183 // 收集信息迭代版
184 public static void dfs2(int cur, int fa, int pmaxv, int pedge) {
185 stacksize = 0;
186 push(cur, fa, pmaxv, pedge, -1);
187 while (stacksize > 0) {
188 pop();
189 if (e == -1) {
190 if (edge > r) {
191 continue;
192 }
193 maxvArr[++cnta] = maxv;
194 edgeArr[cnta] = edge;
195 e = head[u];
196 } else {
197 e = nxt[e];
198 }
199 if (e != 0) {
200 push(u, f, maxv, edge, e);
201 int v = to[e];
202 if (v != f && !vis[v]) {
203 push(to[e], u, Math.max(maxv, weight[e]), edge + 1, -1);
204 }
205 }
206 }
207 }
208
209 public static long calc(int u, int maxv, int edge) {
210 cnta = 0;

Callers 1

calcMethod · 0.95

Calls 3

pushMethod · 0.95
popMethod · 0.95
maxMethod · 0.45

Tested by

no test coverage detected