Package dsa

Class Kruskal


  • public class Kruskal
    extends Object
    An immutable data type to determine the minimum spanning tree (MST) of an edge-weighted graph.
    • Constructor Detail

      • Kruskal

        public Kruskal​(EdgeWeightedGraph G)
        Determines the MST of the edge-weighted graph G.
        Parameters:
        G - the edge-weighted graph.
    • Method Detail

      • edges

        public Iterable<Edge> edges()
        Returns the edges in the MST.
        Returns:
        the edges in the MST.
      • weight

        public double weight()
        Returns the sum of the edge weights in the MST.
        Returns:
        the sum of the edge weights in the MST.
      • main

        public static void main​(String[] args)
        Unit tests the data type.
        Parameters:
        args - the command-line arguments.