Skip to content

Commit 164f328

Browse files
Removing redundant access modifiers.
1 parent fbde45f commit 164f328

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/main/java/com/thealgorithms/randomized/KargerMinCut.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,17 @@ public static KargerOutput findMinCut(Collection<Integer> nodeSet, List<int[]> e
7676

7777
private static class DisjointSetUnion {
7878
private final int[] parent;
79-
public int setCount;
79+
int setCount;
8080

81-
public DisjointSetUnion(int size) {
81+
DisjointSetUnion(int size) {
8282
parent = new int[size];
83-
for (int i = 0; i < size; i++) parent[i] = i;
83+
for (int i = 0; i < size; i++) {
84+
parent[i] = i;
85+
}
8486
setCount = size;
8587
}
8688

87-
public int find(int i) {
89+
int find(int i) {
8890
// If it's not its own parent, then it's not the root of its set
8991
if (parent[i] != i) {
9092
// Recursively find the root of its parent
@@ -96,7 +98,7 @@ public int find(int i) {
9698
return parent[i];
9799
}
98100

99-
public void union(int u, int v) {
101+
void union(int u, int v) {
100102
// Find the root of each node
101103
int rootU = find(u);
102104
int rootV = find(v);
@@ -111,15 +113,15 @@ public void union(int u, int v) {
111113
}
112114
}
113115

114-
public boolean inSameSet(int u, int v) {
116+
boolean inSameSet(int u, int v) {
115117
return find(u) == find(v);
116118
}
117119

118120
/*
119121
This is a verbosity method, it's not a part of the core algorithm,
120122
But it helps us provide more useful output.
121123
*/
122-
public Set<Integer> getAnySet() {
124+
Set<Integer> getAnySet() {
123125
int aRoot = find(0); // Get one of the two roots
124126

125127
Set<Integer> set = new HashSet<>();
@@ -137,19 +139,19 @@ private static class Graph {
137139
private final List<Integer> nodes;
138140
private final List<int[]> edges;
139141

140-
public Graph(Collection<Integer> nodeSet, List<int[]> edges) {
142+
Graph(Collection<Integer> nodeSet, List<int[]> edges) {
141143
this.nodes = new ArrayList<>(nodeSet);
142144
this.edges = new ArrayList<>();
143145
for (int[] e : edges) {
144146
this.edges.add(new int[] {e[0], e[1]});
145147
}
146148
}
147149

148-
public Graph copy() {
150+
Graph copy() {
149151
return new Graph(this.nodes, this.edges);
150152
}
151153

152-
public KargerOutput findMinCut() {
154+
KargerOutput findMinCut() {
153155
DisjointSetUnion dsu = new DisjointSetUnion(nodes.size());
154156
List<int[]> workingEdges = new ArrayList<>(edges);
155157

0 commit comments

Comments
 (0)