- 0
- 0
- 约6.36千字
- 约 40页
- 2017-07-02 发布于湖北
- 举报
Chapter4算法概论概要1
4.6.1 Negative edges * In fact, terminate when no update occurs 4.6.1 Negative edges * 4.6.2 Negative cycles * Negative cycle: the length of cycle is negative The shortest-path problem is ill-posed in graphs with negative cycles. Use the Bellman-Ford algorithm to detect negative cycles After |V|-1 iterations, perform one extra round Negative cycle exists = some dist value is reduced during the extra round -4 4.7 Shortest paths in dags * In any path of a dag, the vertices appear in increasing linearized order. Linearize the dag by DFS, and visit the vertices in sorted order, updating the edges out of each. Find longest paths in a dag: negate all edge lengths. 4.7 Shortest paths in dags * O(|V|+|E|) Exercise 4.1 * Exercise 4.1 * Exercise 4.4 * Exercise 4.4 * Exercise 4.5 * Exercise 4.5 * Exercise 4.10 * Exercise 4.15 * Exercise 4.15 * HOMEWORK Textbook: Ex. 4.2,4.18 * * DESIGN AND ANALYSIS OF ALGORITHMS CHAPTER 4 Paths in graphs 4.1 Distances 4.2 Breadth-first search 4.3 Lengths on edges 4.4 Dijkstra’s algorithm 4.5 Priority queue implementations 4.6 Shortest paths in the presence of negative edges 4.7 Shortest paths in dags * * 4.1 Distances Distance between two nodes: the length of the shortest path between them. DFS identifies all the vertices which can be reached from a starting point, but cannot find shortest paths in graphs. * * 4.2 Breadth-first search * * 4.2 Breadth-first search * * 4.2 Breadth-first search Correctness For each d=0,1,2,…, there is a moment at which All nodes at distance ? d from s have their distances correctly set All other nodes have their distances set to ? The queue contains exactly the nodes at distance d Efficiency Each vertex is put on the queue exactly once, so there are 2|V| queue operations The innermost loop looks at each edge once (in directed graphs) or twice (in undirected graphs), so takes O(|E|) time The overall running time: O(|V| + |E|) * * 4.2 Breadth-first search DFS vs. BFS DFS makes deep incursions into graphs; BF
您可能关注的文档
- CHAPTER 7 书名和标题的翻译概要1.ppt
- Chapter Two词汇学 Sources of English Vocabulary概要1.ppt
- Chapter+6+进程同步与互斥应用例子概要1.ppt
- Chapter two Cultural differences翻译第二章课件(西安石油大学)概要1.ppt
- Chapter+12现代语言学流派概要1.ppt
- Chapter Ⅴ概要1.ppt
- Chapter02 The CPA Profession(审计学英文版)概要1.ppt
- Chapter02_SQL详解概要1.ppt
- Chapter 5偏晶概要1.ppt
- Chapter03 Accounting Cycle (II) Adjustments, Work Sheet and Financial Statements基础会计英文版概要1.ppt
原创力文档

文档评论(0)