Skip to content

Commit 3fe46ba

Browse files
committed
Format code with clang-format
1 parent b13db0e commit 3fe46ba

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/main/java/com/thealgorithms/tree/HeavyLightDecomposition.java

-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public HeavyLightDecomposition(int n) {
3232
position = new int[n + 1];
3333
nodeValue = new int[n + 1];
3434
segmentTree = new int[4 * (n + 1)];
35-
3635
for (int i = 0; i <= n; i++) {
3736
tree[i] = new ArrayList<>();
3837
chainHead[i] = -1;
@@ -56,7 +55,6 @@ public void addEdge(int u, int v) {
5655
private void dfsSize(int node, int parentNode) {
5756
parent[node] = parentNode;
5857
subtreeSize[node] = 1;
59-
6058
for (int child : tree[node]) {
6159
if (child != parentNode) {
6260
depth[child] = depth[node] + 1;
@@ -69,19 +67,16 @@ private void dfsSize(int node, int parentNode) {
6967
private void decompose(int node, int head) {
7068
chainHead[node] = head;
7169
position[node] = positionIndex++;
72-
7370
int heavyChild = -1, maxSubtreeSize = -1;
7471
for (int child : tree[node]) {
7572
if (child != parent[node] && subtreeSize[child] > maxSubtreeSize) {
7673
heavyChild = child;
7774
maxSubtreeSize = subtreeSize[child];
7875
}
7976
}
80-
8177
if (heavyChild != -1) {
8278
decompose(heavyChild, head);
8379
}
84-
8580
for (int child : tree[node]) {
8681
if (child != parent[node] && child != heavyChild) {
8782
decompose(child, child);

src/test/java/com/thealgorithms/tree/HeavyLightDecompositionTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package com.thealgorithms.tree;
22

3-
import org.junit.jupiter.api.BeforeEach;
4-
import org.junit.jupiter.api.Test;
53
import static org.junit.jupiter.api.Assertions.assertEquals;
64
import static org.junit.jupiter.api.Assertions.assertTrue;
75

6+
import org.junit.jupiter.api.BeforeEach;
7+
import org.junit.jupiter.api.Test;
8+
89
class HeavyLightDecompositionTest {
910

1011
private HeavyLightDecomposition hld;

0 commit comments

Comments
 (0)