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

Method calc

src/class187/Code02_Cobweb1.java:214–228  ·  view source on GitHub ↗
(int edge)

Source from the content-addressed store, hash-verified

212 }
213
214 public static void calc(int edge) {
215 cnta = 0;
216 int v1 = to2[edge];
217 dfsLeft(v1, 0, 0, 0, 1);
218 sort(redKey, redPath, 1, cnta);
219 sort(blackKey, blackPath, 1, cnta);
220 for (int i = 2; i <= cnta; i++) {
221 redPath[i] = redPath[i - 1] * redPath[i] % MOD;
222 blackPath[i] = blackPath[i - 1] * blackPath[i] % MOD;
223 }
224 int v2 = to2[edge ^ 1];
225 int red = (color2[edge] == 0 ? 1 : 0);
226 int black = (color2[edge] == 1 ? 1 : 0);
227 dfsRight(v2, 0, red, black, weight2[edge] % MOD);
228 }
229
230 public static void getAns2(int u) {
231 int edge = getCentroidEdge(u, 0);

Callers 1

getAns2Method · 0.95

Calls 3

dfsLeftMethod · 0.95
sortMethod · 0.95
dfsRightMethod · 0.95

Tested by

no test coverage detected