MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / part

Method part

code/graph/hld.cpp:20–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18 sz[u] += csz(adj[parent[adj[u][i]] = u][i]);
19 return sz[u]; }
20 void part(int u) {
21 head[u] = curhead; loc[u] = curloc++;
22 int best = -1;
23 rep(i,0,size(adj[u]))
24 if (adj[u][i] != parent[u] &&
25 (best == -1 || sz[adj[u][i]] > sz[best]))
26 best = adj[u][i];
27 if (best != -1) part(best);
28 rep(i,0,size(adj[u]))
29 if (adj[u][i] != parent[u] && adj[u][i] != best)
30 part(curhead = adj[u][i]); }
31 void build(int r = 0) {
32 curloc = 0, csz(curhead = r), part(r); }
33 int lca(int u, int v) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected