Skip to content

Commit 718f04a

Browse files
author
lennart
committed
fix formatting issues
1 parent 8b0d4a3 commit 718f04a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public CentroidDecomposition(int n, int startingNode) {
5050
throw new IllegalArgumentException("Starting node must be in range 0.." + (n - 1) + " but got " + startingNode);
5151
}
5252
this.startingNode = startingNode;
53-
for (int i = 0; i < n; i++){
53+
for (int i = 0; i < n; i++) {
5454
centroidParent[i] = -1;
5555
tree[i] = new ArrayList<>();
5656
centroidTree[i] = new ArrayList<>();
@@ -139,7 +139,7 @@ public void findCentroid(int src, int previousCentroid) {
139139

140140
for (int node : tree[src]) {
141141
if (centroidMarked[node]) continue;
142-
if (subtreeSizes[node] > (treeSize/2)) {
142+
if (subtreeSizes[node] > (treeSize / 2)) {
143143
heavyChild = node;
144144
break;
145145
}
@@ -158,16 +158,16 @@ public void findCentroid(int src, int previousCentroid) {
158158

159159
for (int node : tree[src]) {
160160
if (!centroidMarked[node]) findCentroid(node, src);
161-
}
162161
}
162+
}
163163

164164
/**
165165
* Applies the given action to all centroid ancestors of the given node,
166166
* including the node itself, walking up via centroidParent[] until the root.
167167
*/
168168
public void forEachAncestor(int centroid, IntConsumer action) {
169169
int curr = centroid;
170-
while (curr != -1){
170+
while (curr != -1) {
171171
action.accept(curr);
172172
curr = getParent(curr);
173173
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void invalidStartingNodeThrows() {
8181

8282
@Test
8383
void IllegalArgumentThrows() {
84-
assertThrows(IllegalArgumentException.class, () -> { new CentroidDecomposition(10, 99);});
84+
assertThrows(IllegalArgumentException.class, () -> { new CentroidDecomposition(10, 99); });
8585
}
8686

8787
@Test

0 commit comments

Comments
 (0)