Package dsa

Class Kruskal

java.lang.Object
dsa.Kruskal

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

    • Kruskal

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

    • 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.