Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

kruskal algorithm

Take all weighted edges and sort them from smallest to highest
Pick the smallest edge and check if it forms a cycle with the existing tree. If so discard. If not add to tree.
Keep picking until you have v-1 edges. 
All answers should have v-1 edges
 
PREVIOUS NEXT
Tagged: #kruskal #algorithm
ADD COMMENT
Topic
Name
5+1 =