Example #1
0
    void Start()
    {
        EdgeWeightedGraph G   = new EdgeWeightedGraph(txt, ' ');
        KruskalMST        mst = new KruskalMST(G);

        foreach (Edge e in mst.edges())
        {
            print(e);
        }
        print(mst.Weight());
    }
    /**/ public static void main(string[] strarr)
    {
        In i = new In(strarr[0]);
        EdgeWeightedGraph ewg        = new EdgeWeightedGraph(i);
        KruskalMST        kruskalMST = new KruskalMST(ewg);
        Iterator          iterator   = kruskalMST.edges().iterator();

        while (iterator.hasNext())
        {
            Edge obj = (Edge)iterator.next();
            StdOut.println(obj);
        }
        StdOut.printf("%.5f\n", new object[]
        {
            java.lang.Double.valueOf(kruskalMST.weight())
        });
    }