示例#1
0
    void Start()
    {
        EdgeWeightedGraph G   = new EdgeWeightedGraph(txt, ' ');
        LazyPrimMST       mst = new LazyPrimMST(G);

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

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