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

Method rebuild

src/class187/Code02_Cobweb1.java:80–102  ·  view source on GitHub ↗
(int u, int fa)

Source from the content-addressed store, hash-verified

78 }
79
80 public static void rebuild(int u, int fa) {
81 int last = 0;
82 for (int e = head1[u]; e > 0; e = next1[e]) {
83 int v = to1[e];
84 int w = weight1[e];
85 int c = color1[e];
86 if (v != fa) {
87 if (last == 0) {
88 last = u;
89 addEdge2(u, v, w, c);
90 addEdge2(v, u, w, c);
91 } else {
92 int add = ++cntn;
93 addEdge2(last, add, 1, -1);
94 addEdge2(add, last, 1, -1);
95 addEdge2(add, v, w, c);
96 addEdge2(v, add, w, c);
97 last = add;
98 }
99 rebuild(v, u);
100 }
101 }
102 }
103
104 public static void getSize(int u, int fa) {
105 siz[u] = 1;

Callers 1

mainMethod · 0.95

Calls 1

addEdge2Method · 0.95

Tested by

no test coverage detected