Moilk.zone

博学出谦逊, 无知生狂傲.

时间 近期更新

# 项目 更新时间
1 Linux图形化系统监视器 2016-09-17
2 ccf认证(更新中) 2016-09-05
3 算法-斐波那契数列 2016-03-18
4 国际跳棋 2016-02-21
5 贪吃蛇 2016-02-20
6 校园卡终端 2016-02-15
7 rolling stone 2016-02-12

推荐 精彩推荐

  分享一个延时Dijkstra算法:

// single-source shortest path problem from s
public LazyDijkstraSP(EdgeWeightedDigraph G, int s) {
    for (DirectedEdge e : G.edges()) { 
        if (e.weight() < 0)
            throw new IllegalArgumentException("edge " + e + " has negative weight");
    }

    pq = new MinPQ<DirectedEdge>(new ByDistanceFromSource());
    marked = new boolean[G.V()];
    edgeTo = new DirectedEdge[G.V()];
    distTo = new double[G.V()];

    // initialize
    for (int v = 0; v < G.V(); v++)
        distTo[v] = Double.POSITIVE_INFINITY;
    distTo[s] = 0.0;
    relax(G, s);

    // run Dijkstra's algorithm
    while (!pq.isEmpty()) {
        DirectedEdge e = pq.delMin();
        int v = e.from(), w = e.to();
        if (!marked[w]) relax(G, w);   // lazy, so w might already have been relaxed
    }

    // check optimality conditions
    assert check(G, s);
}

Your time is limited, so don’t waste it living someone else’s life.…Don’t let the noise of others’ opinions drown out your own inner voice.
———> Steven Jobssina

日历 更新时间: 2016-09-18