Skip to content

Commit 948a974

Browse files
committed
Updated PrismAlgorithm-VI
1 parent 9a32eb6 commit 948a974

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/main/java/com/thealgorithms/graph/PrimAlgorithm.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
*/
1717
public final class PrimAlgorithm {
1818

19-
public PrimAlgorithm(List<List<Edge>> adjacencyList, int vertexCount) {
20-
this.adjacencyList = adjacencyList;
21-
this.vertexCount = vertexCount;
22-
}
23-
2419
/**
2520
* Represents a weighted edge in the graph structure.
2621
* This inner class encapsulates edge information including destination
@@ -156,8 +151,7 @@ public void addEdge(final int source, final int destination, final int weight) {
156151
private void validateVertex(final int vertex) {
157152
if (vertex < 0 || vertex >= vertexCount) {
158153
throw new IllegalArgumentException(
159-
"Vertex " + vertex + " is out of bounds [0, " + (vertexCount - 1) + "]"
160-
);
154+
"Vertex " + vertex + " is out of bounds [0, " + (vertexCount - 1) + "]");
161155
}
162156
}
163157

@@ -204,7 +198,7 @@ public MstResult computeMinimumSpanningTree() {
204198

205199
// Find the source vertex for this edge
206200
int sourceVertex = findSourceVertex(currentVertex, visitedVertices);
207-
mstEdges.add(new int[]{sourceVertex, currentVertex, currentEdge.getWeight()});
201+
mstEdges.add(new int[] {sourceVertex, currentVertex, currentEdge.getWeight()});
208202

209203
// Add all edges from newly visited vertex
210204
for (final Edge neighborEdge : adjacencyList.get(currentVertex)) {

0 commit comments

Comments
 (0)