{"id":165860,"date":"2020-10-11T22:14:39","date_gmt":"2020-10-11T14:14:39","guid":{"rendered":"http:\/\/4563.org\/?p=165860"},"modified":"2020-10-11T22:14:39","modified_gmt":"2020-10-11T14:14:39","slug":"%e4%b8%ba%e4%bb%80%e4%b9%88-bellman-ford-%e7%ae%97%e6%b3%95%e9%9c%80%e8%a6%81%e5%be%aa%e7%8e%af%e9%a1%b6%e7%82%b9%e4%b8%aa%e6%95%b0-1%e6%ac%a1%e5%91%a2%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=165860","title":{"rendered":"\u4e3a\u4ec0\u4e48 Bellman\u2013Ford \u7b97\u6cd5\u9700\u8981\u5faa\u73af\u201c\u9876\u70b9\u4e2a\u6570 &#8211; 1\u201d\u6b21\u5462\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u4e3a\u4ec0\u4e48 Bellman\u2013Ford \u7b97\u6cd5\u9700\u8981\u5faa\u73af\u201c\u9876\u70b9\u4e2a\u6570 &#8211; 1\u201d\u6b21\u5462\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : JasonLaw <\/span>  <span><i><\/i> 0<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u4e0b\u9762\u662f\u6211\u6240\u627e\u5230\u7684\u4e00\u4e9b\u8d44\u6599\uff1a<\/p>\n<ul>\n<li>shortest path &#8211; Why do we need to run the bellman-ford algorithm for n-1 times? &#8211; Computer Science Stack Exchange<\/li>\n<li>graph &#8211; Why need (node number &#8211; 1) iterations in Bellman Ford algorithm to find shortest paths? &#8211; Stack Overflow<\/li>\n<\/ul>\n<p>\u4f46\u6211\u8fd8\u662f\u4e0d\u80fd\u591f\u7406\u89e3 Bellman\u2013Ford \u7b97\u6cd5\u3002<\/p>\n<ul>\n<li>\u4e3a\u4ec0\u4e48 Bellman\u2013Ford \u7b97\u6cd5\u9700\u8981\u5faa\u73af\u201c\u9876\u70b9\u4e2a\u6570 &#8211; 1\u201d\u6b21\uff1f<\/li>\n<li>\u6bcf\u6b21\u5faa\u73af\u5230\u5e95\u4fdd\u8bc1\u4e86\u4ec0\u4e48\u4e0d\u53d8\u6027\uff08 invariant \uff09\uff1f\u6700\u540e\u53ef\u4ee5\u5e2e\u52a9\u8bc1\u660e\uff0c\u7ecf\u8fc7\u201c\u9876\u70b9\u4e2a\u6570 &#8211; 1\u201d\u6b21\u5faa\u73af\u540e\uff0c\u80fd\u591f\u627e\u5230\u9876\u70b9 s \u5230\u5176\u4ed6\u9876\u70b9\u7684\u6700\u77ed\u8ddd\u79bb\u3002<\/li>\n<\/ul><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>6<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3668339\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : litmxs <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u56e0\u4e3a\u6bcf\u6b21\u7684\u677e\u5f1b\u64cd\u4f5c\u90fd\u53ef\u4ee5\u4fdd\u8bc1\u4ece\u4e00\u4e2a\u7ed3\u70b9\u5230\u5176\u76f8\u90bb\u7ed3\u70b9\u7684\u6700\u77ed\u8def\u4f30\u8ba1\u503c\u8fbe\u5230\u6700\u77ed\u8def\u7684\u5b9e\u9645\u503c\uff0c\u4e5f\u5c31\u662f\u4fdd\u8bc1\u4e86\u6240\u6709\u6df1\u5ea6\u4e3a 1 \u7684\u8def\u5f84\u6700\u77ed\u3002n \u6b21\u64cd\u4f5c\u5219\u53ef\u4ee5\u4fdd\u8bc1\u6240\u6709\u6df1\u5ea6\u4e3a n \u7684\u8def\u5f84\u6700\u77ed\u3002\u7531\u4e8e\u5728\u4e0d\u5b58\u5728\u8d1f\u5708\u7684\u60c5\u51b5\u4e0b\uff0c\u4ece s \u51fa\u53d1\u5230\u4efb\u610f\u7ed3\u70b9\u7684\u6700\u77ed\u8def\u4e0d\u4f1a\u7ecf\u8fc7\u540c\u4e00\u4e2a\u7ed3\u70b9\u4e24\u6b21\uff0c\u6240\u4ee5\u6700\u77ed\u8def\u7684\u957f\u5ea6\uff08\u8def\u5f84\u4e0a\u8fb9\u7684\u6570\u91cf\uff09\u4e0d\u4f1a\u8d85\u8fc7|v|-1 \u3002\u6240\u4ee5\u7b97\u6cd5\u53ef\u4ee5\u5728\u6709\u9650\u6b21\u6570\u7684\u677e\u5f1b\u4e0b\u7ed3\u675f\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3668340\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lidlesseye11 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u00b7 \u5173\u4e8e V-1<br \/>https:\/\/www.geeksforgeeks.org\/bellman-ford-algorithm-dp-23\/<br \/>\u53c2\u8003 How does this work? \u90a3\u4e00\u6bb5<\/p>\n<p>\u00b7&#8221;\u4e0d\u53d8\u6027\uff08 invariant \uff09&#8221;\u662f\u5565\u610f\u601d\uff1f                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3668341\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : JasonLaw <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @lidlesseye11 #2 \u6211\u8bf4\u7684\u201c\u4e0d\u53d8\u6027\uff08 invariant \uff09\u201d\u5176\u5b9e\u662f loop invariant -https:\/\/stackoverflow.com\/questions\/3221577\/what-is-a-loop-invariant                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3668342\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lidlesseye11 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @JasonLaw <br \/>\u53d7\u6559\u4e86\u3002<br \/>\u90a3 BF \u7684 loop invariant \u5e94\u8be5\u5c31\u662f After the i-th iteration of the outer loop, the shortest paths with at most i edges are calculated. \u5427                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3668343\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : JasonLaw <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @lidlesseye11 \u5bf9\uff0c\u800c\u4e14\u53ef\u4ee5\u901a\u8fc7\u8fd9\u4e2a loop invariant \u8bc1\u660e\u7b97\u6cd5\u7684\u6b63\u786e\u6027\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3668344\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : JasonLaw <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @litmxs \u611f\u89c9\u4f60\u8bf4\u7684\u201c \u56e0\u4e3a\u6bcf\u6b21\u7684\u677e\u5f1b\u64cd\u4f5c\u90fd\u53ef\u4ee5\u4fdd\u8bc1\u4ece\u4e00\u4e2a\u7ed3\u70b9\u5230\u5176\u76f8\u90bb\u7ed3\u70b9\u7684\u6700\u77ed\u8def\u4f30\u8ba1\u503c\u8fbe\u5230\u6700\u77ed\u8def\u7684\u5b9e\u9645\u503c\uff0c\u4e5f\u5c31\u662f\u4fdd\u8bc1\u4e86\u6240\u6709\u6df1\u5ea6\u4e3a 1 \u7684\u8def\u5f84\u6700\u77ed\u3002n \u6b21\u64cd\u4f5c\u5219\u53ef\u4ee5\u4fdd\u8bc1\u6240\u6709\u6df1\u5ea6\u4e3a n \u7684\u8def\u5f84\u6700\u77ed\u3002\u201d\u602a\u602a\u7684\uff0c\u4f46\u662f\u6211\u53c8\u8bf4\u4e0d\u592a\u4e0a\u6765\u662f\u54ea\u91cc\u6709\u95ee\u9898\uff0c\u66ff\u6362\u4e3a\u201c After the i-th iteration of the outer loop, the shortest paths with at most i edges are calculated.\u201d\u4f1a\u66f4\u597d\u7406\u89e3\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3a\u4ec0\u4e48 Bellman\u2013Ford &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/165860"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=165860"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/165860\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=165860"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=165860"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=165860"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}