@@ -0,0 +1,1637 @@
+package me.alivecode.algs4;%0A%0Aimport edu.princeton.cs.algs4.StdOut;%0A%0Aimport java.util.DoubleSummaryStatistics;%0A%0A/**%0A * Created by oujt on 17-3-8.%0A */%0Apublic class DirectedEdge %7B%0A    private final int v;%0A    private final int w;%0A    private final double weight;%0A%0A    /**%0A     * Initializes a directed edge.%0A     *%0A     * @param from the start vertex%0A     * @param to the end vertex%0A     * @param weight the weight%0A     */%0A    public DirectedEdge(int from, int to, double weight) %7B%0A        if (from %3C 0 %7C%7C to %3C 0) throw new IllegalArgumentException(%22vertices must be nonnegative integers%22);%0A        if (Double.isNaN(weight)) throw new IllegalArgumentException(%22weight is NaN%22);%0A        v = from;%0A        w = to;%0A        this.weight = weight;%0A    %7D%0A%0A    /**%0A     * Returns the start vertex of this edge.%0A     *%0A     * @return the start vertex of this edge%0A     */%0A    public int from() %7B%0A        return v;%0A    %7D%0A%0A    /**%0A     * Returns the end vertex of this edge.%0A     *%0A     * @return the end vertex of this edge%0A     */%0A    public int to() %7B%0A        return w;%0A    %7D%0A%0A    /**%0A     * Returns the weight of this edge.%0A     *%0A     * @return the weight of this edge%0A     */%0A    public double weight() %7B%0A        return weight;%0A    %7D%0A%0A    /**%0A     * Returns a string represents this directed edge.%0A     *%0A     * @return a string represents this directed edge.%0A     */%0A    public String toString() %7B%0A        String s = String.format(%22%25s %25s %255.5f%22, v, w, weight);%0A        return s;%0A    %7D%0A%0A    // unit test code%0A    public static void main(String%5B%5D args) %7B%0A        DirectedEdge e = new DirectedEdge(1, 2, 0.776);%0A        StdOut.println(e);%0A    %7D%0A%7D%0A

Add directed weight edge.