Skip to content

Commit

Permalink
Minor update to exercise 4.3.23
Browse files Browse the repository at this point in the history
  • Loading branch information
reneargento committed May 8, 2020
1 parent 9c7ba7a commit 2436a22
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/chapter4/section3/Exercise23_VyssotskyAlgorithm.java
Expand Up @@ -2,6 +2,7 @@

import chapter1.section3.Queue;
import chapter1.section3.Stack;
import chapter3.section5.HashSet;
import edu.princeton.cs.algs4.StdOut;

/**
Expand All @@ -17,8 +18,10 @@ public Queue<Edge> minimumSpanningTree(EdgeWeightedGraph edgeWeightedGraph) {

for(Edge edge : edgeWeightedGraph.edges()) {
putativeTree.addEdge(edge);
HashSet<Integer> vertexToSearch = new HashSet<>();
vertexToSearch.add(edge.either());

EdgeWeightedCycle edgeWeightedCycle = new EdgeWeightedCycle(putativeTree);
EdgeWeightedCycle edgeWeightedCycle = new EdgeWeightedCycle(putativeTree, vertexToSearch);

// If a cycle was formed, delete the maximum-weight edge in it
if (edgeWeightedCycle.hasCycle()) {
Expand Down

0 comments on commit 2436a22

Please sign in to comment.