亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? chap25.htm

?? CLRS-算法導(dǎo)論
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
<HTML><HEAD>

<TITLE>Intro to Algorithms: CHAPTER 25: SINGLE-SOURCE SHORTEST PATHS</TITLE></HEAD><BODY BGCOLOR="#FFFFFF">

<a href="chap26.htm"><img align=right src="../../images/next.gif" alt="Next Chapter" border=0></A>
<a href="toc.htm"><img align=right src="../../images/toc.gif" alt="Return to Table of Contents" border=0></A>
<a href="chap24.htm"><img align=right src="../../images/prev.gif" alt="Previous Chapter" border=0></A>


<h1><a name="08bd_17d1">CHAPTER 25: SINGLE-SOURCE SHORTEST PATHS<a name="08bd_17d1"></h1><P>
<a name="08bd_17c6"><a name="08bd_17c7">A motorist wishes to find the shortest possible route from Chicago to Boston. Given a road map of the United States on which the distance between each pair of adjacent intersections is marked, how can we determine this shortest route? <P>
One possible way is to enumerate all the routes from Chicago to Boston, add up the distances on each route, and select the shortest. It is easy to see, however, that even if we disallow routes that contain cycles, there are millions of possibilities, most of which are simply not worth considering. For example, a route from Chicago to Houston to Boston is obviously a poor choice, because Houston is about a thousand miles out of the way.<P>
<a name="08bd_17c8"><a name="08bd_17c9"><a name="08bd_17ca"><a name="08bd_17cb"><a name="08bd_17cc">In this chapter and in Chapter 26, we show how to solve such problems efficiently. In a <I><B>shortest-paths problem</I></B>, we are given a weighted, directed graph <I>G</I> = (<I>V</I>, <I>E</I>), with weight function <I>w</I> : <I>E</I> <img src="../images/arrow12.gif"> <B>R</B> mapping edges to real-valued weights. The <I><B>weight</I></B> of path p = <img src="../images/lftwdchv.gif"><I>v<SUB>0</I></SUB>, <I>v</I><SUB>1</SUB>, . . . , <img src="../images/upsil12.gif"><I><SUB>k</I></SUB><img src="../images/wdrtchv.gif"> is the sum of the weights of its constituent edges:<P>
<img src="514_a.gif"><P>
We define the <I><B>shortest-path weight</I></B> from <I>u</I> to <I>v</I> by<P>
<img src="514_b.gif"> if there is a path from <I>u</I> to <I>v</I>, otherwise.<P>
<a name="08bd_17cd"><a name="08bd_17ce">A <I><B>shortest path</I></B><I> </I>from vertex <I>u</I> to vertex <I>v</I> is then defined as any path <I>p</I> with weight<I> w </I>(<I>p</I>)<I> = </I><img src="../images/delta12.gif"><I>(</I>u, v<I>)</I>.<P>
In the Chicago-to-Boston example, we can model the road map as a graph: vertices represent intersections, edges represent road segments between intersections, and edge weights represent road distances. Our goal is to find a shortest path from a given intersection in Chicago (say, Clark St. and Addison Ave.) to a given intersection in Boston (say, Brookline Ave. and Yawkey Way).<P>
Edge weights can be interpreted as metrics other than distances. They are often used to represent time, cost, penalties, lossage, or any other quantity that accumulates linearly along a path and that one wishes to minimize.<P>
<a name="08bd_17cf"><a name="08bd_17d0">The breadth-first-search algorithm from Section 23.2 is a shortest-paths algorithm that works on unweighted graphs, that is, graphs in which each edge can be considered to have unit weight. Because many of the concepts from breadth-first search arise in the study of shortest paths in weighted graphs, the reader is encouraged to review Section 23.2 before proceeding.<P>





<h2>Variants</h2><P>
<a name="08bf_17d1"><a name="08bf_17d2">In this chapter, we shall focus on the <I><B>single-source shortest-paths problem</I>:</B> given a graph <I>G</I> = (<I>V</I>, <I>E</I>), we want to find a shortest path from a given <I><B>source</I></B> vertex <I>s</I> <img src="../images/memof12.gif"> <I>V</I> to every vertex <I>v</I> <img src="../images/memof12.gif"> <I>V</I>. Many other problems can be solved by the algorithm for the single-source problem, including the following variants.<P>
<a name="08bf_17d3"><a name="08bf_17d4"><B>Single-destination shortest-paths problem:</B>     Find a shortest path to a given <I><B>destination</I></B> vertex <I>t</I> from every vertex <I>v</I>. By reversing the direction of each edge in the graph, we can reduce this problem to a single-source problem.<P>
<a name="08bf_17d5"><B>Single-pair shortest-path problem:</B>     Find a shortest path from <I>u</I> to <I>v</I> for given vertices <I>u</I> and <I>v</I>. If we solve the single-source problem with source vertex <I>u</I>, we solve this problem also. Moreover, no algorithms for this problem are known that run asymptotically faster than the best single-source algorithms in the worst case.<P>
<a name="08bf_17d6"><B>All-pairs shortest-paths problem:</B>     Find a shortest path from <I>u</I> to <I>v</I> for every pair of vertices <I>u</I> and <I>v.</I> This problem can be solved by running a single-source algorithm once from each vertex; but it can usually be solved faster, and its structure is of interest in its own right. Chapter 26 addresses the all-pairs problem in detail.<P>
<P>







<h2>Negative-weight edges</h2><P>
<a name="08c0_17d7"><a name="08c0_17d8"><a name="08c0_17d9"><a name="08c0_17da"><a name="08c0_17db">In some instances of the single-source shortest-paths problem, there may be edges whose weights are negative. If the graph <I>G</I> = (<I>V, E</I>) contains no negative-weight cycles reachable from the source <I>s</I>, then for all <I>v </I><img src="../images/memof12.gif"><I> V</I>, the shortest-path weight <img src="../images/delta12.gif"><I></I>(<I>s</I>, <I>v</I>) remains well defined, even if it has a negative value. If there is a negative-weight cycle reachable from <I>s</I>, however, shortest-path weights are not well defined. No path from s to a vertex on the cycle can be a shortest path--a lesser-weight path can always be found that follows the proposed &quot;shortest&quot; path and then traverses the negative-weight cycle. If there is a negative-weight cycle on some path from <I>s</I> to <I>v</I>, we define <img src="../images/delta12.gif"> <I></I>(<I>s,v</I>)<I> </I> = -<img src="../images/infin.gif">.<P>
Figure 25.1 illustrates the effect of negative weights on shortest-path weights. Because there is only one path from <I>s</I> to <I>a</I> (the path <img src="../images/lftwdchv.gif"><I>s, a</I><img src="../images/wdrtchv.gif">), <img src="../images/delta12.gif"><I></I>(<I>s, a</I> = <I>w</I>(<I>s, a</I>) = 3. Similarly, there is only one path from <I>s</I> to <I>b</I>, and so <img src="../images/delta12.gif"><I></I>(<I>s, b</I>) = <I>w</I>(<I>s, a</I>) + <I>w</I>(<I>a, b</I>) = 3 + (-4) = - 1. There are infinitely many paths from <I>s</I> to <I>c</I>: <img src="../images/lftwdchv.gif"><I>s, c</I><img src="../images/wdrtchv.gif">, <img src="../images/lftwdchv.gif"><I>s, c, d, c</I><img src="../images/wdrtchv.gif">, <img src="../images/lftwdchv.gif"><I>s, c, d, c, d, c</I><img src="../images/wdrtchv.gif">, and so on. Because the cycle <img src="../images/lftwdchv.gif"><I>c, d, c</I><img src="../images/wdrtchv.gif"> has weight 6 + (-3) = 3 &gt; 0, the shortest path from <I>s</I> to <I>c</I> is <img src="../images/lftwdchv.gif"><I>s, c</I><img src="../images/wdrtchv.gif">, with weight <img src="../images/delta12.gif"><I></I>(<I>s, c</I>) = 5. Similarly, the shortest path from <I>s</I> to <I>d</I> is <img src="../images/lftwdchv.gif"><I>s, c, d</I><img src="../images/wdrtchv.gif">, with weight <img src="../images/delta12.gif"><I></I>(<I>s, d</I>) = <I>w</I>(<I>s, c</I>) + <I>w</I>(<I>c, d</I>) = 11. Analogously, there are infinitely many paths from <I>s</I> to <I>e</I>: <img src="../images/lftwdchv.gif"><I>s, e</I><img src="../images/wdrtchv.gif">, <img src="../images/lftwdchv.gif"><I>s, e, f, e</I><img src="../images/wdrtchv.gif">, <img src="../images/lftwdchv.gif"><I>s, e, f, e, f, e</I><img src="../images/wdrtchv.gif">, and so on. Since the cycle <img src="../images/lftwdchv.gif"><I>e, f, e</I><img src="../images/wdrtchv.gif"> has weight 3 + (-6) = -3 &lt; 0, however, there is no shortest path from <I>s</I> to <I>e</I>. By traversing the negative-weight cycle <img src="../images/lftwdchv.gif"><I>e, f, e</I><img src="../images/wdrtchv.gif"> arbitrarily many times, we can find paths from <I>s</I> to <I>e</I> with arbitrarily large negative weights, and so <img src="../images/delta12.gif"><I></I>(<I>s, e</I>) = -<img src="../images/infin.gif">. Similarly, <img src="../images/delta12.gif"><I></I>(<I>s, f</I>) -<img src="../images/infin.gif">. Because <I>g</I> is reachable from <I>f</I>, we can also find paths with arbitrarily large negative weights from <I>s</I> to <I>g</I>, and <img src="../images/delta12.gif"><I></I>(<I>s, g</I>) = -<img src="../images/infin.gif">. Vertices <I>h, i, and j</I> also form a negative-weight cycle. They are not reachable from <I>s</I>, however, and so <img src="../images/delta12.gif"><I></I>(<I>s, h</I>) = <img src="../images/delta12.gif"><I></I>(<I>s, i</I>) = <img src="../images/delta12.gif"><I></I>(<I>s, j</I>) = <img src="../images/infin.gif">.<P>
<img src="516_a.gif"><P>
<h4><a name="08c0_17dc">Figure 25.1  Negative edge weights in a directed graph. Shown within each vertex is its shortest-path weight from source s. Because vertices e and f form a negative-weight cycle reachable from s, they have shortest-path weights of -<img src="../images/infin.gif">. Because vertex g is reachable from a vertex whose shortest-path weight is -<img src="../images/infin.gif">, it, too, has a shortest-path weight of -<img src="../images/infin.gif">. Vertices such as h, i, and j are not reachable from s, and so their shortest-path weights are <img src="../images/infin.gif">, even though they lie on a negative-weight cycle.<a name="08c0_17dc"></sub></sup></h4><P>
Some shortest-paths algorithms, such as Dijkstra's algorithm, assume that all edge weights in the input graph are nonnegative, as in the road-map example. Others, such as the Bellman-Ford algorithm, allow negative-weight edges in the input graph and produce a correct answer as long as no negative-weight cycles are reachable from the source. Typically, if there is such a negative-weight cycle, the algorithm can detect and report its existence.<P>
<P>







<h2>Representing shortest paths</h2><P>
<a name="08c1_17dc">We often wish to compute not only shortest-path weights, but the vertices on the shortest paths as well. The representation we use for shortest paths is similar to the one we used for breadth-first trees in Section 23.2. Given a graph <I>G</I> = (<I>V, E</I>), we maintain for each vertex <I>v</I> <img src="../images/memof12.gif"> <I>V</I> a <I><B>predecessor</I></B><I> </I><img src="../images/piuc.gif"><I></I>[<I>v</I>] that is either another vertex or <FONT FACE="Courier New" SIZE=2>NIL</FONT>. The shortest-paths algorithms in this chapter set the <img src="../images/piuc.gif"> attributes so that the chain of predecessors originating at a vertex <I>v</I> runs backwards along a shortest path from <I>s</I> to <I>v</I>. Thus, given a vertex <I>v</I> for which <img src="../images/piuc.gif"><I></I>[<I>v</I>] <img src="../images/noteq.gif"> <FONT FACE="Courier New" SIZE=1>NIL</FONT>, the procedure <FONT FACE="Courier New" SIZE=2>PRINT</FONT>-<FONT FACE="Courier New" SIZE=2>PATH</FONT> (<I>G</I>, <I>s, v</I>) from Section 23.2 can be used to print a shortest path from <I>s</I> to <I>v</I>.<P>
<a name="08c1_17dd">During the execution of a shortest-paths algorithm, however, the <img src="../images/piuc.gif"><I> </I>values need not indicate shortest paths. As in breadth-first search, we shall be interested in the <I><B>predecessor subgraph</I></B> <I>G</I><img src="../images/piuc.gif"><I> = (</I>V<SUB><img src="../images/piuc.gif"></SUB>, E<SUB><img src="../images/pi14.gif"></SUB>) induced by the <img src="../images/piuc.gif"><I></I> values. Here again, we define the vertex set <I>V<SUB><FONT FACE="Courier New" SIZE=2></I></SUB><img src="../images/piuc.gif"></FONT>, to be the set of vertices of <I>G</I> with non-<FONT FACE="Courier New" SIZE=2>NIL</FONT> predecessors, plus the source <I>s</I>:<P>
<pre><I>V</I><SUB></SUB><img src="../images/piuc.gif"><SUB> = {<I>v</I> <img src="../images/memof12.gif"> <I>V</I> : <img src="../images/piuc.gif">[<I>v</I>] <img src="../images/noteq.gif"> NIL} <img src="../images/wideu.gif"> {<I>s</I>} .</sub></sup></pre><P>
The directed edge set <I>E<FONT FACE="Courier New" SIZE=2></I><img src="../images/piuc.gif"><I></I></FONT> is the set of edges induced by the <img src="../images/piuc.gif"><I></I> values for vertices in <I>V</I><img src="../images/piuc.gif"><I><SUB></I>:<P>

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品写真福利| 中文字幕亚洲电影| 亚洲午夜免费视频| 欧日韩精品视频| 亚洲国产精品久久一线不卡| 欧美三级资源在线| 久久精品理论片| 久久久亚洲精品一区二区三区| 国产尤物一区二区在线| 国产精品久久一卡二卡| 欧美一a一片一级一片| 日韩中文字幕亚洲一区二区va在线| 欧美一区二区三区啪啪| 国产精品99精品久久免费| 亚洲欧洲精品成人久久奇米网| 日本高清不卡视频| 日本欧美肥老太交大片| 偷拍一区二区三区| 欧美成人性福生活免费看| 国产成人在线色| 亚洲激情图片一区| 日韩欧美三级在线| 成人动漫在线一区| 日韩av一区二区在线影视| 久久精品夜色噜噜亚洲a∨| 色综合久久久久综合| 日本特黄久久久高潮| 亚洲精品一区二区三区香蕉| 91麻豆免费观看| 首页国产欧美日韩丝袜| 日本一区二区三区国色天香| 在线精品视频一区二区三四| 美女一区二区久久| ●精品国产综合乱码久久久久| 欧美一区二区三区四区在线观看 | 国产日本欧美一区二区| 91偷拍与自偷拍精品| 免费亚洲电影在线| **欧美大码日韩| xvideos.蜜桃一区二区| 欧美日韩在线播放三区| 成人免费视频免费观看| 蜜臀久久99精品久久久画质超高清 | 国产精品国产三级国产三级人妇| 欧美日韩国产综合视频在线观看| 懂色av中文一区二区三区 | 欧美成人一区二区三区| 色哟哟一区二区| 国产成人a级片| 蜜臀久久99精品久久久久久9| 亚洲精品视频观看| 国产欧美一区二区精品性色超碰| 欧美日韩一卡二卡| 成人a免费在线看| 久久国产乱子精品免费女| 一区二区三区中文免费| 久久久无码精品亚洲日韩按摩| 成人av电影免费观看| 国产成人在线电影| 国产综合色产在线精品| 日韩av一区二区三区四区| 一区二区三区视频在线看| 久久综合九色综合欧美就去吻 | 久久精品一区二区三区四区| 91精品蜜臀在线一区尤物| 欧美在线免费视屏| 色综合久久综合网97色综合| 丁香婷婷综合色啪| 美女性感视频久久| 亚洲自拍都市欧美小说| 伊人色综合久久天天人手人婷| www成人在线观看| 欧美久久免费观看| 欧美日韩一区小说| 色国产综合视频| 色94色欧美sute亚洲线路一ni| 99久久久精品免费观看国产蜜| 另类欧美日韩国产在线| 久久国产视频网| 日韩精彩视频在线观看| 视频一区在线播放| 天堂影院一区二区| 麻豆91在线看| 久久精品国产成人一区二区三区| 日本在线不卡视频一二三区| 亚洲香蕉伊在人在线观| 亚洲一区在线视频| 亚洲成人免费电影| 蜜桃av噜噜一区| 国产在线乱码一区二区三区| 国产成人午夜99999| 99综合电影在线视频| 91蜜桃视频在线| 欧美色精品天天在线观看视频| 制服丝袜在线91| 欧美va在线播放| 国产欧美日韩亚州综合| 国产欧美一区二区精品秋霞影院 | 亚洲女同ⅹxx女同tv| 亚洲国产成人porn| 蜜臀av亚洲一区中文字幕| 国产一区二区三区美女| 97se亚洲国产综合自在线不卡| 欧美三区在线观看| 久久久久久久网| 一区二区视频免费在线观看| 日韩av一区二区在线影视| 国产精品亚洲视频| 99re热这里只有精品免费视频| 欧美日韩国产影片| 国产肉丝袜一区二区| 夜夜操天天操亚洲| 国产伦精品一区二区三区免费 | 福利一区在线观看| 欧美在线视频全部完| 26uuu精品一区二区三区四区在线| 国产精品国产三级国产专播品爱网| 亚洲电影中文字幕在线观看| 国产精品一区在线| 欧美日韩一区二区三区视频| 国产三级欧美三级日产三级99| 一区二区久久久久久| 国产又粗又猛又爽又黄91精品| 欧美性受xxxx黑人xyx性爽| 精品成人免费观看| 一区二区三区日韩精品视频| 国产乱码精品一品二品| 欧美日韩成人一区二区| 亚洲午夜精品网| 国产一区二区日韩精品| 欧美日韩国产影片| 亚洲三级小视频| 国产一区二区精品久久91| 欧美精品一二三| 国产精品国产馆在线真实露脸| 首页综合国产亚洲丝袜| 91福利精品第一导航| 国产精品久久久久影视| 激情综合色丁香一区二区| 欧美性猛交xxxx乱大交退制版| 国产精品私人自拍| 狠狠色丁香婷综合久久| 欧美日韩国产精品自在自线| 中文字幕在线播放不卡一区| 国产精品123区| 欧美tickling挠脚心丨vk| 日韩精品欧美精品| 欧美日韩在线播| 亚洲国产精品久久一线不卡| 日本乱人伦一区| 亚洲视频免费在线| 床上的激情91.| 欧美国产精品专区| 国产伦精一区二区三区| 久久久综合网站| 国产主播一区二区| 欧美xxxxx牲另类人与| 美女www一区二区| 日韩一区二区三区四区| 日韩国产欧美视频| 3d动漫精品啪啪1区2区免费| 性做久久久久久久久| 精品视频免费在线| 亚洲成人先锋电影| 欧美精品18+| 日韩中文字幕麻豆| 日韩欧美国产不卡| 久久av中文字幕片| 欧美精品一区二区在线观看| 国产真实乱子伦精品视频| 久久人人爽爽爽人久久久| 国产一区二区在线看| 久久久国际精品| 成人手机在线视频| 国产精品久久777777| 91蜜桃在线观看| 亚洲第一福利视频在线| 日韩一区二区精品在线观看| 美国十次综合导航| 久久久www成人免费毛片麻豆| 成人性色生活片| 亚洲伦理在线免费看| 欧美日免费三级在线| 老汉av免费一区二区三区| 久久综合色播五月| www..com久久爱| 亚洲风情在线资源站| 精品理论电影在线| www.欧美色图| 日韩av一二三| 欧美三级日韩三级| 亚洲成国产人片在线观看| 欧美日韩精品欧美日韩精品一| 日韩av二区在线播放| 国产亚洲精品超碰| 91国在线观看| 久久99精品久久久久久国产越南 | 高清不卡在线观看| 亚洲欧美偷拍三级| 欧美一区二区三区成人|