single-source shortest path in directed graph

two common operations vertex initialisation and relax

vertex initialisation -> set key of each vertex to max value; set precedence to null; set key of s (start vertex) to 0;

relax(u,v,w) -> set key of vertex v to lower value u.key + w(u,v) if any. If yes, set v.precedence to u

- Bellman-Ford, O(VE)

  • take n-1 rounds of relaxes of each edge.
  • can be used to detect negative weight loop which doesn't has shorted path

- topological sort for PERT (Program Execute and Review Technique),  O(V + E)

  • sort vertices in topological order
  • for each vertex, relax on its all adjacent vertices.
  • find key path of PERT

- Dijkstra, O((V + E)lgv), only for non-negative weight graph

  • sort vertex in non-decreasing order on key of vertex (put vertices in priority queue)
  • take vertex from the queue and relax on its all adjacent vertices. order is updated in the queue.

- shortest path on directed graph for System of Difference Constraints

  • constraints, xj-xi <= w. (i,j belong to V), the number of constraints should exceed |V|
  • n = |V|, is number of vertices for xi.
  • w is weight of edge (vi, vj)
  • add one more node v0 and edges (v0, vi) with weight of 0
  • shortest path (v0, v1), (v0, v2)... is solution of xi.



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值