{"id":111518,"date":"2026-10-01T10:16:41","date_gmt":"2026-10-01T02:16:41","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/111518.html"},"modified":"2026-10-01T10:16:41","modified_gmt":"2026-10-01T02:16:41","slug":"%e5%9b%be%e8%a7%a3%e5%9b%be%e8%ae%ba%e6%a0%b8%e5%bf%83%ef%bc%9a%e4%bb%8e%e5%9f%ba%e7%a1%80%e5%88%b0%e9%82%bb%e6%8e%a5%e7%9f%a9%e9%98%b5%ef%bc%8c%e9%82%bb%e6%8e%a5%e8%a1%a8%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/111518.html","title":{"rendered":"\u56fe\u89e3\u56fe\u8bba\u6838\u5fc3\uff1a\u4ece\u57fa\u7840\u5230\u90bb\u63a5\u77e9\u9635\uff0c\u90bb\u63a5\u8868\u5b9e\u73b0"},"content":{"rendered":"<h2><\/h2>\n<h2>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0\u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"200\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261001021635-6abdc28359edf.jpg\" width=\"200\" \/><\/h2>\n<p>&#x1f525;keyipatience:\u4e2a\u4eba\u4e3b\u9875<\/p>\n<p>&#x1f3ac;\u4f5c\u8005\u7b80\u4ecb&#xff1a;C\/C&#043;&#043;\u540e\u7aef\u5f00\u53d1\u5b66\u4e60\u8005<\/p>\n<p>&#x1f31f;\u4e13\u680f\u4f20\u9001\u95e8&#xff1a;\u300ac&#043;&#043;\u300b\u300alinux\u300b\u300ac&#043;&#043;\u9ad8\u9636\u6570\u636e\u7ed3\u6784\u300b\u300ac&#043;&#043;\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u300b<\/p>\n<p>\u2b50\ufe0fpatience is key in life<\/p>\n<h2><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1216\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261001021635-6abdc283d75ed.png\" width=\"1952\" \/><\/h2>\n<h2>\u56fe<\/h2>\n<h3 style=\"background-color:transparent\"><span style=\"color:#0d0016\">\u56fe\u7684\u57fa\u7840\u77e5\u8bc6<\/span><\/h3>\n<p><span style=\"color:#0d0016\">1.\u56fe G&#061;(V,E)&#xff0c;\u7531\u4e24\u90e8\u5206\u7ec4\u6210<\/span><\/p>\n<ul>\n<li>V&#xff08;\u9876\u70b9\u96c6&#xff09;&#xff1a;\u4e00\u5806\u70b9&#xff0c;\u4e0d\u80fd\u4e3a\u7a7a<\/li>\n<li>E&#xff08;\u8fb9\u96c6&#xff09;&#xff1a;\u70b9\u548c\u70b9\u4e4b\u95f4\u7684\u8fde\u7ebf&#xff0c;\u4ee3\u8868\u70b9\u4e4b\u95f4\u7684\u5173\u7cfb<\/li>\n<\/ul>\n<p><span style=\"color:#0d0016\">2.\u65e0\u5411\u56fe vs \u6709\u5411\u56fe<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u65e0\u5411\u56fe&#xff08;G1\u3001G2&#xff09;<\/span>&#xff1a;\u8fb9\u4e0d\u5e26\u7bad\u5934&#xff0c;(x,y) \u548c (y,x) \u662f\u540c\u4e00\u6761\u8fb9&#xff0c;\u53cc\u5411\u4e92\u901a\u3002<\/li>\n<li>\u6709\u5411\u56fe&#xff08;G3\u3001G4&#xff09;&#xff1a;\u8fb9\u5e26\u7bad\u5934&#xff0c;&lt;x,y&gt; \u548c &lt;y,x&gt; \u662f\u4e24\u6761\u4e0d\u4e00\u6837\u7684\u8fb9&#xff0c;\u65b9\u5411\u4e0d\u80fd\u53cd\u8fc7\u6765\u3002<\/li>\n<\/ul>\n<p><span style=\"color:#0d0016\">3.\u5b8c\u5168\u56fe<\/span><\/p>\n<ul>\n<li>\u65e0\u5411\u5b8c\u5168\u56fe&#xff1a;n \u4e2a\u70b9&#xff0c;\u4efb\u610f\u4e24\u70b9\u4e4b\u95f4\u90fd\u6709\u4e00\u6761\u8fb9&#xff0c;\u603b\u8fb9\u6570\u516c\u5f0fn(n-1)\/2;&#8211;(G1)<\/li>\n<li>\u6709\u5411\u5b8c\u5168\u56fe&#xff1a;n \u4e2a\u70b9&#xff0c;\u4efb\u610f\u4e24\u70b9\u4e4b\u95f4\u4e92\u76f8\u6709\u4e00\u5bf9\u53cd\u5411\u7684\u8fb9,\u603b\u8fb9\u6570\u516c\u5f0fn(n-1);&#8211;(G2)<\/li>\n<\/ul>\n<p><span style=\"color:#0d0016\">4.\u90bb\u63a5\u9876\u70b9<\/span><\/p>\n<ul>\n<li>\u65e0\u5411\u56fe&#xff1a;\u6709\u8fb9\u76f4\u63a5\u76f8\u8fde\u7684\u4e24\u4e2a\u70b9&#xff0c;\u4e92\u4e3a\u90bb\u63a5\u70b9\u3002<\/li>\n<li>\u6709\u5411\u56fe&#xff1a;\u8fb9&lt;u,v&gt;&#xff0c;u \u6307\u5411 v \u2192 u \u90bb\u63a5\u5230 v&#xff0c;v \u90bb\u63a5\u81ea u\u3002<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"673\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261001021638-6abdc286b8295.png\" width=\"820\" \/><\/p>\n<p><span style=\"color:#0d0016\">5.\u9876\u70b9\u7684\u5ea6<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u65e0\u5411\u56fe<\/span>&#xff1a;\u5ea6 deg(v) &#061; \u548c\u8fd9\u4e2a\u70b9\u76f8\u8fde\u7684\u8fb9\u7684\u6570\u91cf\u3002<\/li>\n<li>\u6709\u5411\u56fe&#xff1a;\n<ul>\n<li>\u51fa\u5ea6 outdeg&#xff1a;\u4ece\u8fd9\u4e2a\u70b9\u51fa\u53d1\u7684\u8fb9\u6570\u91cf<\/li>\n<li>\u5165\u5ea6 indeg&#xff1a;\u6307\u5411\u8fd9\u4e2a\u70b9\u7684\u8fb9\u6570\u91cf<\/li>\n<li>\u603b\u5ea6&#xff1a;\u5165\u5ea6&#043;\u51fa\u5ea6<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u63e1\u624b\u5b9a\u7406&#xff1a;\u56fe\u4e2d\u6240\u6709\u9876\u70b9\u5ea6\u6570\u4e4b\u548c &#061; \u8fb9\u6570 \u00d7 2<\/p>\n<p><span style=\"color:#0d0016\">6.\u8def\u5f84 &amp; \u8def\u5f84\u957f\u5ea6<\/span><\/p>\n<ul>\n<li>\u8def\u5f84&#xff1a;\u4ece\u8d77\u70b9\u987a\u7740\u8fb9\u8d70\u5230\u7ec8\u70b9&#xff0c;\u7ecf\u8fc7\u7684\u9876\u70b9\u5e8f\u5217\u3002<\/li>\n<li>\u4e0d\u5e26\u6743\u56fe&#xff1a;\u8def\u5f84\u957f\u5ea6 &#061; \u8fd9\u6761\u8def\u4e0a\u8fb9\u7684\u6761\u6570<\/li>\n<li>\u5e26\u6743\u56fe&#xff1a;\u8fb9\u4e0a\u6709\u6570\u5b57&#xff08;\u6743\u503c&#xff09;&#xff0c;\u8def\u5f84\u957f\u5ea6 &#061; \u8def\u4e0a\u6240\u6709\u8fb9\u6743\u503c\u76f8\u52a0<\/li>\n<li>\u6743\u503c&#xff1a;\u8fb9\u9644\u5e26\u7684\u4fe1\u606f&#xff0c;\u53ef\u4ee5\u4ee3\u8868\u8ddd\u79bb\u3001\u65f6\u95f4\u3001\u6210\u672c\u3002<\/li>\n<\/ul>\n<p>\u4f8b\u5b50&#xff1a;\u56fe\u91cc\u7684\u4ea4\u901a\u7f51\u7edc\u56fe&#xff0c;\u8fb9\u4e0a\u6570\u5b57\u5c31\u662f\u8def\u7a0b&#xff1b;\u65bd\u5de5\u8fdb\u5ea6\u56fe&#xff0c;\u6570\u5b57\u4ee3\u8868\u5de5\u671f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"506\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261001021638-6abdc286e7348.png\" width=\"934\" \/><\/p>\n<p><span style=\"color:#0d0016\">7.\u7b80\u5355\u8def\u5f84 &amp; \u56de\u8def&#xff08;\u73af&#xff09;<\/span><\/p>\n<ul>\n<li>\u7b80\u5355\u8def\u5f84&#xff1a;\u8def\u5f84\u91cc\u6240\u6709\u9876\u70b9\u90fd\u4e0d\u91cd\u590d<\/li>\n<li>\u56de\u8def&#xff08;\u73af&#xff09;&#xff1a;\u8def\u5f84\u8d77\u70b9\u548c\u7ec8\u70b9\u662f\u540c\u4e00\u4e2a\u70b9\u3002<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"334\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261001021639-6abdc287164cb.png\" width=\"702\" \/><\/p>\n<p><span style=\"color:#fe2c24\">8.\u5b50\u56fe<\/span><\/p>\n<p>\u539f\u56feG&#061;(V,E)&#xff0c;\u65b0\u56feG1&#061;(V1,E1)\u53ea\u8981\u6ee1\u8db3&#xff1a;V1\u662f\u539f\u56fe\u9876\u70b9\u7684\u5b50\u96c6&#xff0c;E1\u662f\u539f\u56fe\u8fb9\u7684\u5b50\u96c6&#xff0c;G1\u5c31\u662fG\u7684\u5b50\u56fe\u3002<\/p>\n<p>\u53ef\u4ee5\u5c11\u70b9\u3001\u5c11\u8fb9&#xff1b;\u4f46\u4e0d\u80fd\u51fa\u73b0\u539f\u56fe\u6ca1\u6709\u7684\u70b9\u6216\u8005\u8fb9\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"705\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261001021639-6abdc287269cd.png\" width=\"851\" \/><\/p>\n<p><span style=\"color:#0d0016\">9.\u8fde\u901a\u56fe&#xff08;\u65e0\u5411\u56fe&#xff09; &amp; \u5f3a\u8fde\u901a\u56fe&#xff08;\u6709\u5411\u56fe&#xff09;<\/span><\/p>\n<ul>\n<li>\u65e0\u5411\u8fde\u901a\u56fe&#xff1a;\u4efb\u610f\u4e24\u4e2a\u9876\u70b9\u4e4b\u95f4\u90fd\u80fd\u627e\u5230\u8def\u5f84\u8d70\u901a\u3002\u00a0<\/li>\n<li>\u5f3a\u8fde\u901a\u56fe&#xff08;\u6709\u5411\u56fe&#xff09;&#xff1a;\u4efb\u610f\u4e00\u5bf9\u70b9(u\u3001v)&#xff0c;\u65e2\u80fd\u4eceu\u8d70\u5230v&#xff0c;\u4e5f\u80fd\u4ecev\u8d70\u56deu&#xff0c;\u53cc\u5411\u4e92\u901a\u3002\u00a0<\/li>\n<\/ul>\n<p><span style=\"color:#fe2c24\">10.\u751f\u6210\u6811<\/span><\/p>\n<ul>\n<li>\u5fc5\u987b\u5305\u542b\u539f\u56fe\u5168\u90e8 n \u4e2a\u9876\u70b9&#xff08;\u70b9\u4e00\u4e2a\u4e0d\u80fd\u5c11&#xff01;&#xff09;<\/li>\n<li>\u8fb9\u662f\u539f\u56fe\u91cc\u7684\u8fb9&#xff0c;\u4f46\u53ea\u4fdd\u7559\u6700\u5c11\u6570\u91cf&#xff0c;\u4fdd\u8bc1\u6240\u6709\u70b9\u8fde\u901a\u5373\u53ef<\/li>\n<li>\u8fb9\u6570&#xff1a;n \u4e2a\u9876\u70b9 \u2192 n\u22121 \u6761\u8fb9<\/li>\n<\/ul>\n<p>2\u5c31\u662f1\u7684\u751f\u6210\u6811<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"198\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261001021639-6abdc2875318f.png\" width=\"445\" \/><\/p>\n<p><span style=\"color:#fe2c24\">\u6700\u5c0f\u751f\u6210\u6811 (MST)&#xff1a;\u6240\u6709\u751f\u6210\u6811\u91cc&#xff0c;\u8fb9\u6743\u603b\u548c\u6700\u5c0f\u7684\u90a3\u4e00\u68f5\u3002<\/span><\/p>\n<h3><span style=\"color:#0d0016\">\u90bb\u63a5\u77e9\u9635<\/span><\/h3>\n<p>\u6838\u5fc3\u601d\u60f3&#xff1a;\u7528\u4e8c\u7ef4\u6570\u7ec4&#xff08;\u77e9\u9635&#xff09;\u5b58\u9876\u70b9\u4e4b\u95f4\u6709\u6ca1\u6709\u8fb9 \u77e9\u9635 edge[i][j] \u4ee3\u8868\u9876\u70b9 i \u5230\u9876\u70b9 j \u7684\u8fde\u63a5\u60c5\u51b5\u3002<\/p>\n<h4><span style=\"color:#0d0016\">\u90bb\u63a5\u77e9\u9635\u7c7b\u578b<\/span><\/h4>\n<p><span style=\"color:#0d0016\">1.\u65e0\u5411\u56fe G1<\/span><\/p>\n<p>&#xff08;1&#xff09;\u65e0\u5411\u56fe\u90bb\u63a5\u77e9\u9635\u4e00\u5b9a\u5bf9\u79f0&#xff1a;edge[i][j] &#061; edge[j][i]<\/p>\n<p>&#xff08;2&#xff09;edge[i][j]&#061;1&#xff1a;i \u548c j \u4e4b\u95f4\u6709\u8fb9&#xff1b;\u7b49\u4e8e 0&#xff1a;\u6ca1\u6709\u8fb9<\/p>\n<p><span style=\"color:#0d0016\">2.\u6709\u5411\u56fe G2<\/span><\/p>\n<p>\u77e9\u9635\u4e0d\u4e00\u5b9a\u5bf9\u79f0&#xff0c;\u8fb9\u6709\u65b9\u5411&#xff01; edge[A][B]&#061;1 \u4ee3\u8868 A\u2192B&#xff1b;edge[B][A]&#061;1 \u4ee3\u8868 B\u2192A&#xff0c;\u4e8c\u8005\u76f8\u4e92\u72ec\u7acb\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"541\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261001021639-6abdc2875f8dd.png\" width=\"600\" \/><\/p>\n<p><span style=\"color:#0d0016\">3.\u5e26\u6743\u56fe<\/span><\/p>\n<ul>\n<li>\u4e24\u70b9\u8fde\u901a&#xff1a;\u77e9\u9635\u586b\u6743\u503c<\/li>\n<li>\u4e24\u70b9\u4e0d\u8fde\u901a&#xff1a;\u586b\u65e0\u7a77\u5927\u221e<\/li>\n<li>\u81ea\u5df1\u5230\u81ea\u5df1&#xff1a;\u586b 0<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"227\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261001021639-6abdc287ab8e4.png\" width=\"500\" \/><\/p>\n<h4><span style=\"color:#fe2c24\">\u4e00\u6b65\u6b65\u5b9e\u73b0\u90bb\u63a5\u77e9\u9635<\/span><\/h4>\n<p><span style=\"color:#0d0016\">1.\u6a21\u677f\u53c2\u6570<\/span><\/p>\n<p>template&lt;class V,class W,W MAX_W,bool Direction&#061;false&gt;<\/p>\n<p>&#xff08;1&#xff09;V&#xff1a;\u9876\u70b9\u7684\u6570\u636e\u7c7b\u578b&#xff08;\u9876\u70b9\u5b58\u4ec0\u4e48&#xff0c;\u6bd4\u5982string\/char&#xff09;<\/p>\n<p>&#xff08;2&#xff09;W&#xff1a;\u8fb9\u7684\u6743\u91cd\u7c7b\u578b&#xff08;int\u3001double&#xff09;<\/p>\n<p>&#xff08;3&#xff09;MAX_W&#xff1a;\u4ee3\u8868\u4e0d\u5b58\u5728\u8fb9\u7684\u6743\u91cd\u503c&#xff08;\u65e0\u7a77\u5927&#xff09;<\/p>\n<p>&#xff08;4&#xff09;Direction&#061;false&#xff1a;\u9ed8\u8ba4\u65e0\u5411\u56fe&#xff1b;\u4f20 true \u5c31\u662f\u6709\u5411\u56fe<\/p>\n<p>\u90bb\u63a5\u77e9\u9635\u6838\u5fc3&#xff1a;_matrix[i][j] \u4ee3\u8868\u9876\u70b9 i \u2192 \u9876\u70b9 j \u7684\u8fb9\u6743\u91cd&#xff1b;\u7b49\u4e8e MAX_W \u4ee3\u8868\u6ca1\u6709\u8fd9\u6761\u8fb9<\/p>\n<p><span style=\"color:#0d0016\">2.\u79c1\u6709\u6210\u5458<\/span><\/p>\n<p>vector&lt;V&gt;_vertexs;         \/\/ \u4fdd\u5b58\u6240\u6709\u9876\u70b9<br \/>\nvector &lt;vector&lt;W&gt;&gt;_matrix; \/\/ \u90bb\u63a5\u77e9\u9635&#xff0c;\u4e8c\u7ef4\u6570\u7ec4<br \/>\nmap&lt;V,int&gt;_indexmap;       \/\/ \u9876\u70b9 -&gt; \u4e0b\u6807 \u7684\u6620\u5c04&#xff1a;\u6bd4\u5982\u9876\u70b9&#039;A&#039;\u6620\u5c04\u52300\u53f7\u4e0b\u6807<\/p>\n<p><span style=\"color:#0d0016\">3.\u6784\u9020\u51fd\u6570<\/span><\/p>\n<p>Graph(const V* vertexs, int n)<br \/>\n{<br \/>\n_vertexs.assign(vertexs, vertexs &#043; n);<br \/>\nfor (int i &#061; 0; i &lt; n; i&#043;&#043;)<br \/>\n{<br \/>\n_indexmap[_vertexs[i]] &#061; i;<br \/>\n}<br \/>\n_matrix.assign(n, vector&lt;W&gt;(n, MAX_W));<br \/>\n}<\/p>\n<p>&#xff08;1&#xff09;\u628a\u4f20\u5165\u9876\u70b9\u6570\u7ec4\u653e\u5230_vertexs<\/p>\n<p>&#xff08;2&#xff09;\u5faa\u73af\u5efa\u7acb\u9876\u70b9\u540d \u2192 \u6570\u7ec4\u4e0b\u6807map<\/p>\n<p>\u597d\u5904&#xff1a;\u7528\u6237\u4f20\u9876\u70b9&#xff08;\u6bd4\u5982&#039;a&#039;&#xff09;&#xff0c;\u4e0d\u7528\u81ea\u5df1\u8bb0\u6570\u5b57\u4e0b\u6807&#xff0c;\u7c7b\u5185\u90e8\u81ea\u52a8\u8f6c\u6210\u77e9\u9635\u7d22\u5f15<\/p>\n<p>&#xff08;3&#xff09;\u521b\u5efan*n\u7684\u4e8c\u7ef4\u77e9\u9635&#xff0c;\u5168\u90e8\u521d\u59cb\u5316\u4e3aMAX_W&#xff08;\u9ed8\u8ba4\u65e0\u8fb9&#xff09;<\/p>\n<p><span style=\"color:#0d0016\">4.GetVertexIndex<\/span><\/p>\n<p>int GetVertexIndex(const V&amp; v)<br \/>\n{<br \/>\nauto ret &#061; _indexmap.find(v);<br \/>\nif (ret &#061;&#061; _indexmap.end())return -1;<br \/>\nelse return ret-&gt;second;<br \/>\n}<\/p>\n<p>\u8f93\u5165\u9876\u70b9&#xff0c;\u8fd4\u56de\u5b83\u5728\u77e9\u9635\u91cc\u7684\u4e0b\u6807&#xff1b;\u627e\u4e0d\u5230\u8fd4\u56de &#8211; 1\u3002<\/p>\n<p><span style=\"color:#0d0016\">4._AddEdge<\/span><\/p>\n<p>void _AddEdge(int srci, int dsti,const W&amp;w)<br \/>\n{<br \/>\n_matrix[srci][dsti] &#061; w;<br \/>\nif (Direction &#061;&#061; false)_matrix[dsti][srci] &#061; w;\/\/\u65e0\u5411\u56fe\u8981\u5efa\u7acb2\u6761<br \/>\n} <\/p>\n<p>&#xff08;1&#xff09;srci\u8d77\u70b9\u4e0b\u6807&#xff0c;dsti\u7ec8\u70b9\u4e0b\u6807<\/p>\n<p>&#xff08;2&#xff09;\u6709\u5411\u56fe&#xff1a;\u53ea\u8bbe\u7f6ematrix[srci][dsti]&#061;w&#xff0c;\u5355\u5411\u8fb9<\/p>\n<p>&#xff08;3&#xff09;\u65e0\u5411\u56fe&#xff08;\u9ed8\u8ba4&#xff09;&#xff1a;\u540c\u65f6\u8bbe\u7f6ematrix[dsti][srci]&#061;w&#xff0c;\u53cc\u5411\u8fb9<\/p>\n<p><span style=\"color:#0d0016\">5.AddEdge<\/span><\/p>\n<p>void AddEdge(const V&amp; src, const V&amp; dst, const W&amp; w)<br \/>\n{<br \/>\nint srci &#061; GetVertexIndex(src);<br \/>\nint dsti &#061; GetVertexIndex(dst);<br \/>\n_AddEdge(srci, dsti, w);<br \/>\n}<\/p>\n<p>\u5bf9\u5916\u4f7f\u7528&#xff1a;\u76f4\u63a5\u4f20\u9876\u70b9\u540d\u5b57&#xff0c;\u4e0d\u7528\u7ba1\u4e0b\u6807&#xff0c;\u5185\u90e8\u81ea\u52a8\u8f6c\u4e0b\u6807\u8c03\u7528_AddEdge\u3002 \u793a\u4f8b&#xff1a;g.AddEdge(&#039;A&#039;,&#039;B&#039;,5)<\/p>\n<p><span style=\"color:#0d0016\">6<\/span><span style=\"color:#0d0016\">.Print<\/span><\/p>\n<p>void Print()<br \/>\n{<br \/>\n\/\/3 \u90e8\u5206\u6253\u5370&#xff1a;<br \/>\n\/\/ 1. \u6253\u5370\u9876\u70b9\u548c\u4e0b\u6807\u6620\u5c04\u5173\u7cfb<br \/>\nfor (int i &#061; 0; i &lt; _vertexs.size(); i&#043;&#043;)<br \/>\n{<br \/>\ncout &lt;&lt; _vertexs[i] &lt;&lt; &#034;-&#034; &lt;&lt; i &lt;&lt; &#034; &#034;;<br \/>\n}<br \/>\ncout &lt;&lt; endl;<br \/>\ncout &lt;&lt; endl;<\/p>\n<p>cout &lt;&lt; &#034;  &#034;;\/\/\u7a7a\u4e8c\u683c<br \/>\nfor (int i &#061; 0; i &lt; _vertexs.size(); &#043;&#043;i)<br \/>\n{<br \/>\ncout &lt;&lt; i &lt;&lt; &#034; &#034;;<br \/>\n}<br \/>\ncout &lt;&lt; endl;<\/p>\n<p>\/\/ 2. \u6253\u5370\u90bb\u63a5\u77e9\u9635<br \/>\nfor (int i &#061; 0; i &lt; _matrix.size(); &#043;&#043;i) {<br \/>\ncout &lt;&lt; i &lt;&lt; &#034; &#034;;<br \/>\nfor (int j &#061; 0; j &lt; _matrix[i].size(); &#043;&#043;j) {<br \/>\nif (_matrix[i][j] !&#061; MAX_W)<br \/>\ncout &lt;&lt; _matrix[i][j] &lt;&lt; &#034; &#034;;<br \/>\nelse<br \/>\ncout &lt;&lt; &#034;#&#034; &lt;&lt; &#034; &#034;;<br \/>\n}<br \/>\ncout &lt;&lt; endl;<br \/>\n}<br \/>\ncout &lt;&lt; endl &lt;&lt; endl;<\/p>\n<p>\/\/ 3. \u6253\u5370\u6240\u6709\u7684\u8fb9&#xff0c;\u6ce8\u610f:\u6253\u5370\u8fb9\u7684\u5faa\u73af i&lt;j&#xff1a;\u5982\u679c\u662f\u6709\u5411\u56fe\u65f6&#xff0c;\u6709\u5411\u8fb9\u4f1a\u6f0f\u6389&#xff0c;\u4e0d\u80fd\u76f4\u63a5\u590d\u7528,\u9700\u8981\u53bb\u6389<br \/>\nfor (size_t i &#061; 0; i &lt; _matrix.size(); &#043;&#043;i) {<br \/>\nfor (size_t j &#061; 0; j &lt; _matrix[i].size(); &#043;&#043;j) {<br \/>\nif (i &lt; j &amp;&amp; _matrix[i][j] !&#061; MAX_W) {<br \/>\ncout &lt;&lt; _vertexs[i] &lt;&lt; &#034;-&#034; &lt;&lt; _vertexs[j] &lt;&lt; &#034;:&#034; &lt;&lt; _matrix[i][j] &lt;&lt; endl;<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\n} <\/p>\n<h4><span style=\"color:#0d0016\">\u5b8c\u6574\u4ee3\u7801&#xff1a;<\/span><\/h4>\n<p>template&lt;class V,class W,W MAX_W,bool Direction&#061;false&gt;<br \/>\nclass Graph<br \/>\n{<br \/>\npublic:<br \/>\nGraph(){}<br \/>\nGraph(const V* vertexs, int n)<br \/>\n{<br \/>\n_vertexs.assign(vertexs, vertexs &#043; n);\/\/assign(\u521d\u59cb\u8fed\u4ee3\u5668&#xff0c;\u7ed3\u675f\u8fed\u4ee3\u5668&#xff09;<br \/>\nfor (int i &#061; 0; i &lt; n; i&#043;&#043;)<br \/>\n{<br \/>\n_indexmap[_vertexs[i]] &#061; i;\/\/\u5efa\u7acb\u6620\u5c04<br \/>\n}<br \/>\n_matrix.assign(n, vector&lt;W&gt;(n, MAX_W));<br \/>\n}<br \/>\nint GetVertexIndex(const V&amp; v)<br \/>\n{<br \/>\nauto ret &#061; _indexmap.find(v);<br \/>\nif (ret &#061;&#061; _indexmap.end())return -1;<br \/>\nelse return ret-&gt;second;<br \/>\n}<br \/>\nvoid _AddEdge(int srci, int dsti,const W&amp;w)<br \/>\n{<br \/>\n_matrix[srci][dsti] &#061; w;<br \/>\nif (Direction &#061;&#061; false)_matrix[dsti][srci] &#061; w;\/\/\u65e0\u5411\u56fe\u8981\u5efa\u7acb2\u6761<br \/>\n}<br \/>\nvoid AddEdge(const V&amp; src, const V&amp; dst, const W&amp; w)<br \/>\n{<br \/>\nint srci &#061; GetVertexIndex(src);<br \/>\nint dsti &#061; GetVertexIndex(dst);<br \/>\n_matrix[srci][dsti] &#061; w;<br \/>\nif (Direction &#061;&#061; false)_matrix[dsti][srci] &#061; w;\/\/\u65e0\u5411\u56fe\u8981\u5efa\u7acb2\u6761<br \/>\n}<br \/>\n    void Print()<br \/>\n{<br \/>\n\/\/3\u90e8\u5206\u6253\u5370&#xff1a;<br \/>\n\/\/ 1. \u6253\u5370\u9876\u70b9\u548c\u4e0b\u6807\u6620\u5c04\u5173\u7cfb<br \/>\nfor (int i &#061; 0; i &lt; _vertexs.size(); i&#043;&#043;)<br \/>\n{<br \/>\ncout &lt;&lt; _vertexs[i] &lt;&lt; &#034;-&#034; &lt;&lt; i &lt;&lt; &#034; &#034;;<br \/>\n}<br \/>\ncout &lt;&lt; endl;<br \/>\ncout &lt;&lt; endl;<\/p>\n<p>cout &lt;&lt; &#034;  &#034;;\/\/\u7a7a\u4e8c\u683c<br \/>\nfor (int i &#061; 0; i &lt; _vertexs.size(); &#043;&#043;i)<br \/>\n{<br \/>\ncout &lt;&lt; i &lt;&lt; &#034; &#034;;<br \/>\n}<br \/>\ncout &lt;&lt; endl;<\/p>\n<p>\/\/ 2. \u6253\u5370\u90bb\u63a5\u77e9\u9635<br \/>\nfor (int i &#061; 0; i &lt; _matrix.size(); &#043;&#043;i) {<br \/>\ncout &lt;&lt; i &lt;&lt; &#034; &#034;;<br \/>\nfor (int j &#061; 0; j &lt; _matrix[i].size(); &#043;&#043;j) {<br \/>\nif (_matrix[i][j] !&#061; MAX_W)<br \/>\ncout &lt;&lt; _matrix[i][j] &lt;&lt; &#034; &#034;;<br \/>\nelse<br \/>\ncout &lt;&lt; &#034;#&#034; &lt;&lt; &#034; &#034;;<br \/>\n}<br \/>\ncout &lt;&lt; endl;<br \/>\n}<br \/>\ncout &lt;&lt; endl &lt;&lt; endl;<\/p>\n<p>\/\/ 3. \u6253\u5370\u6240\u6709\u7684\u8fb9&#xff0c;\u6ce8\u610f:\u6253\u5370\u8fb9\u7684\u5faa\u73af i&lt;j&#xff1a;\u5982\u679c\u662f\u6709\u5411\u56fe\u65f6&#xff0c;\u6709\u5411\u8fb9\u4f1a\u6f0f\u6389&#xff0c;\u4e0d\u80fd\u76f4\u63a5\u590d\u7528,\u9700\u8981\u53bb\u6389<br \/>\nfor (size_t i &#061; 0; i &lt; _matrix.size(); &#043;&#043;i) {<br \/>\nfor (size_t j &#061; 0; j &lt; _matrix[i].size(); &#043;&#043;j) {<br \/>\nif (i &lt; j &amp;&amp; _matrix[i][j] !&#061; MAX_W) {<br \/>\ncout &lt;&lt; _vertexs[i] &lt;&lt; &#034;-&#034; &lt;&lt; _vertexs[j] &lt;&lt; &#034;:&#034; &lt;&lt; _matrix[i][j] &lt;&lt; endl;<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\n}<\/p>\n<p>private:<br \/>\nvector&lt;V&gt;_vertexs;<br \/>\nvector &lt;vector&lt;W&gt;&gt;_matrix;<br \/>\nmap&lt;V,int&gt;_indexmap;<br \/>\n}; <\/p>\n<p><span style=\"color:#0d0016\">\u6d4b\u8bd5\u7528\u4f8b&#xff1a;<\/span><\/p>\n<p>void TestGraph()<br \/>\n{<br \/>\nGraph&lt;char, int, INT_MAX, true&gt; g(&#034;0123&#034;, 4);<br \/>\ng.AddEdge(&#039;0&#039;, &#039;1&#039;, 1);<br \/>\ng.AddEdge(&#039;0&#039;, &#039;3&#039;, 4);<br \/>\ng.AddEdge(&#039;1&#039;, &#039;3&#039;, 2);<br \/>\ng.AddEdge(&#039;1&#039;, &#039;2&#039;, 9);<br \/>\ng.AddEdge(&#039;2&#039;, &#039;3&#039;, 8);<br \/>\ng.AddEdge(&#039;2&#039;, &#039;1&#039;, 5);<br \/>\ng.AddEdge(&#039;2&#039;, &#039;0&#039;, 3);<br \/>\ng.AddEdge(&#039;3&#039;, &#039;2&#039;, 6);<br \/>\ng.Print();<br \/>\n} <\/p>\n<p><span style=\"color:#0d0016\">\u7ed3\u679c&#xff1a;<\/span> <img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"411\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261001021639-6abdc287c0d19.png\" width=\"343\" \/><\/p>\n<h3><span style=\"color:#0d0016\">\u90bb\u63a5\u8868&#xff08;\u94fe\u8868\u7248\u90bb\u63a5\u8868&#xff09;<\/span><\/h3>\n<p>\u90bb\u63a5\u8868&#xff1a;\u4f7f\u7528\u6570\u7ec4\u8868\u793a\u9876\u70b9\u7684\u96c6\u5408&#xff0c;\u4f7f\u7528\u94fe\u8868\u8868\u793a\u8fb9\u7684\u5173\u7cfb\u3002<\/p>\n<h4><span style=\"color:#0d0016\">\u90bb\u63a5\u8868\u7c7b\u578b<\/span><\/h4>\n<p><span style=\"color:#0d0016\">1. \u65e0\u5411\u56fe\u90bb\u63a5\u8868\u5b58\u50a8<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"480\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261001021639-6abdc287d637e.png\" width=\"789\" \/><\/p>\n<p><span style=\"color:#0d0016\">2.\u6709\u5411\u56fe\u90bb\u63a5\u8868\u5b58\u50a8<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"691\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261001021640-6abdc28810bff.png\" width=\"960\" \/><\/p>\n<p>\u5b9e\u9645\u6211\u4eec\u5b9e\u73b0\u7684\u65f6\u5019\u4e0d\u7528\u5206\u522b\u5b9e\u73b0\u5165\u8fb9\u8868\u548c\u51fa\u8fb9\u88682\u4e2a\u8868&#xff0c;\u666e\u901a\u90bb\u63a5\u8868\u53ea\u5b58\u3010\u51fa\u8fb9\u3011&#xff0c;\u4e00\u6761\u5c31\u591f&#xff1b;\u4e0d\u9700\u8981\u989d\u5916\u518d\u5355\u72ec\u5f00\u4e00\u5f20\u8868\u4e13\u95e8\u5b58\u5165\u8fb9\u3002\u5e76\u4e14\u7edd\u5927\u591a\u6570\u7b97\u6cd5&#xff08;DFS\u3001BFS\u3001Dijkstra\u3001\u62d3\u6251\u6392\u5e8f&#xff09;<span style=\"color:#fe2c24\">\u53ea\u9700\u8981\u904d\u5386\u4e00\u4e2a\u70b9\u6240\u6709\u5f80\u5916\u8d70\u7684\u8fb9<\/span>&#xff0c;\u53ea\u9700\u8981\u51fa\u8fb9\u8868&#xff0c;\u53ea\u7528_linktable\u5c31\u8db3\u591f\u3002<\/p>\n<h4><span style=\"color:#fe2c24\">\u4e00\u6b65\u6b65\u5b9e\u73b0\u90bb\u63a5\u8868&#xff1a;<\/span><\/h4>\n<p><span style=\"color:#0d0016\">1.Edge \u8fb9\u7ed3\u6784\u4f53&#xff08;\u5355\u94fe\u8868\u8282\u70b9&#xff09;<\/span><\/p>\n<p>template&lt;class W&gt;<br \/>\nstruct Edge<br \/>\n{<br \/>\n    int _dsti;         \/\/ \u76ee\u6807\u9876\u70b9\u7684\u4e0b\u6807&#xff08;\u91cd\u70b9&#xff01;\u4e0d\u662f\u9876\u70b9\u503c&#xff0c;\u662f\u5728_vertexs\u91cc\u7684\u7d22\u5f15&#xff09;<br \/>\n    W _w;              \/\/ \u8fb9\u6743<br \/>\n    Edge&lt;W&gt;* next;    \/\/ \u6307\u5411\u4e0b\u4e00\u6761\u8fb9\u7684\u6307\u9488&#xff0c;\u90bb\u63a5\u8868\u662f\u5355\u94fe\u8868<\/p>\n<p>    Edge&lt;W&gt;(const int dsti&#061;-1,const W&amp;w&#061;W())<br \/>\n        :_dsti(dsti)<br \/>\n        ,_w(w)<br \/>\n        ,next(nullptr)<br \/>\n    { }<br \/>\n};<\/p>\n<p><span style=\"color:#0d0016\">2. Graph \u7c7b\u6210\u5458\u53d8\u91cf&#xff08;private&#xff09;<\/span><\/p>\n<p>vector&lt;V&gt; _vertexs;         \/\/ \u9876\u70b9\u6570\u7ec4<br \/>\nmap&lt;V, int&gt; _indexmap;      \/\/ key:\u9876\u70b9\u503cV&#xff0c;value:\u9876\u70b9\u4e0b\u6807i,\u9876\u70b9\u548c\u4e0b\u6807\u6620\u5c04<br \/>\nvector&lt;Edge*&gt; _linktable;   \/\/ \u90bb\u63a5\u8868&#xff01;\u6570\u7ec4&#xff0c;\u6bcf\u4e2a\u5143\u7d20\u662f\u8fb9\u94fe\u8868\u5934\u6307\u9488<\/p>\n<p>eg&#xff1a;\u00a0\u9876\u70b9&#xff1a;A(0), B(1), C(2) _linktable[0] \u662f\u9876\u70b9 A \u7684\u8fb9\u94fe\u8868\u5934&#xff0c;\u5b58 A \u6240\u6709\u51fa\u53bb\u7684\u8fb9 _linktable[1] \u662f\u9876\u70b9 B \u7684\u8fb9\u94fe\u8868\u5934<\/p>\n<p><span style=\"color:#0d0016\">3.\u6784\u9020\u51fd\u6570<\/span><\/p>\n<p>Graph(const V* vertexs, int n)<br \/>\n{<br \/>\n    _vertexs.assign(vertexs, vertexs &#043; n);<br \/>\n    for (int i &#061; 0; i &lt; n; i&#043;&#043;)<br \/>\n    {<br \/>\n        _indexmap[_vertexs[i]] &#061; i; \/\/ \u9876\u70b9\u503c\u6620\u5c04\u5230\u4e0b\u6807<br \/>\n    }<br \/>\n    _linktable.assign(n, nullptr); \/\/ n\u4e2a\u9876\u70b9&#xff0c;n\u6761\u7a7a\u94fe\u8868&#xff0c;\u521d\u59cb\u90fd\u662fnullptr<br \/>\n}<\/p>\n<p><span style=\"color:#0d0016\">4.GetVertexIndex<\/span><\/p>\n<p>int GetVertexIndex(const V&amp; v)<br \/>\n{<br \/>\n    auto ret &#061; _indexmap.find(v);<br \/>\n    if (ret &#061;&#061; _indexmap.end())return -1;<br \/>\n    else return ret-&gt;second;<br \/>\n}<\/p>\n<p><span style=\"color:#0d0016\">5.AddEdge \u6dfb\u52a0\u8fb9&#xff08;\u6838\u5fc3&#xff01;\u533a\u5206\u6709\u5411 \/ \u65e0\u5411&#xff09;<\/span><\/p>\n<p>void AddEdge(const V&amp; src, const V&amp; dst, const W&amp;w)<br \/>\n{<br \/>\n    int srci &#061; GetVertexIndex(src); \/\/\u6e90\u9876\u70b9\u4e0b\u6807<br \/>\n    int dsti &#061; GetVertexIndex(dst); \/\/\u76ee\u6807\u9876\u70b9\u4e0b\u6807<\/p>\n<p>    \/\/ \u5934\u63d2\u6cd5&#xff1a;\u65b0\u5efa\u8fb9&#xff0c;\u63d2\u5230srci\u5bf9\u5e94\u7684\u94fe\u8868\u5934\u90e8<br \/>\n    Edge* newedge &#061; new Edge(dsti,w);<br \/>\n    newedge-&gt;next &#061; _linktable[srci];<br \/>\n    _linktable[srci] &#061; newedge;<\/p>\n<p>    \/\/ Direction&#061;false \u65e0\u5411\u56fe&#xff1a;\u53cc\u5411\u90fd\u8981\u52a0\u8fb9<br \/>\n    if (Direction &#061;&#061; false)<br \/>\n    {<br \/>\n        Edge* newedge2 &#061; new Edge(srci, w);<br \/>\n        newedge2-&gt;next &#061; _linktable[dsti];<br \/>\n        _linktable[dsti] &#061; newedge2;<br \/>\n    }<br \/>\n}<\/p>\n<p><span style=\"color:#0d0016\">6.Print<\/span><\/p>\n<p>void Print()<br \/>\n{<br \/>\n\/\/ \u7b2c\u4e00\u90e8\u5206&#xff1a;\u6253\u5370\u3010\u9876\u70b9\u7f16\u53f7\u548c\u540d\u5b57\u3011<br \/>\nfor (size_t i &#061; 0; i &lt; _vertexs.size(); &#043;&#043;i)<br \/>\n{<br \/>\ncout &lt;&lt; &#034;[&#034; &lt;&lt; i &lt;&lt; &#034;]&#034; &lt;&lt; &#034;-&gt;&#034; &lt;&lt; _vertexs[i] &lt;&lt; endl;<br \/>\n}<br \/>\ncout &lt;&lt; endl;<\/p>\n<p>\/\/ \u7b2c\u4e8c\u90e8\u5206&#xff1a;\u904d\u5386\u90bb\u63a5\u8868 _linktables<br \/>\nfor (size_t i &#061; 0; i &lt; _linktable.size(); &#043;&#043;i)<br \/>\n{<br \/>\n\/\/ \u6253\u5370\u8d77\u70b9&#xff1a;\u9876\u70b9\u540d\u5b57[\u4e0b\u6807]<br \/>\ncout &lt;&lt; _vertexs[i] &lt;&lt; &#034;[&#034; &lt;&lt; i &lt;&lt; &#034;]&#034; &lt;&lt; &#034;-&gt;&#034;;<\/p>\n<p>\/\/ cur\u62ff\u5230\u8fd9\u4e2a\u9876\u70b9\u5bf9\u5e94\u7684\u8fb9\u94fe\u8868\u5934\u6307\u9488<br \/>\nEdge* cur &#061; _linktable[i];<br \/>\nwhile (cur)<br \/>\n{<br \/>\n\/\/ cur-&gt;_dsti&#xff1a;\u76ee\u6807\u9876\u70b9\u4e0b\u6807<br \/>\n\/\/ _vertexs[cur-&gt;_dsti]&#xff1a;\u76ee\u6807\u9876\u70b9\u540d\u5b57<br \/>\ncout &lt;&lt; _vertexs[cur-&gt;_dsti] &lt;&lt; &#034;[&#034; &lt;&lt; cur-&gt;_dsti &lt;&lt; &#034;]&#034; &lt;&lt; cur-&gt;_w &lt;&lt; &#034;-&gt;&#034;;<br \/>\ncur &#061; cur-&gt;_next;<br \/>\n}<br \/>\ncout &lt;&lt; &#034;nullptr&#034; &lt;&lt; endl;<br \/>\n}<br \/>\n} <\/p>\n<h4><span style=\"color:#0d0016\">\u5b8c\u6574\u4ee3\u7801&#xff1a;<\/span><\/h4>\n<p>namespace LinkTable<br \/>\n{<br \/>\ntemplate&lt;class W&gt;<br \/>\nstruct Edge<br \/>\n{<br \/>\n\/\/\u4e0d\u9700\u8981srci<br \/>\nint _dsti;<br \/>\nW _w;<br \/>\nEdge&lt;W&gt;* next;<\/p>\n<p>Edge&lt;W&gt;(const int dsti &#061; -1,const W&amp; w&#061;W())<br \/>\n:_dsti(dsti)<br \/>\n, _w(w)<br \/>\n, next(nullptr)<br \/>\n{<br \/>\n}<br \/>\n};<br \/>\ntemplate&lt;class V, class W, bool Direction &#061; false&gt;<br \/>\nclass Graph<br \/>\n{<br \/>\npublic:<br \/>\ntypedef Edge&lt;W&gt; Edge;<br \/>\nGraph(const V* vertexs, int n)<br \/>\n{<br \/>\n_vertexs.assign(vertexs, vertexs &#043; n);\/\/assign(\u521d\u59cb\u8fed\u4ee3\u5668&#xff0c;\u7ed3\u675f\u8fed\u4ee3\u5668&#xff09;<br \/>\nfor (int i &#061; 0; i &lt; n; i&#043;&#043;)<br \/>\n{<br \/>\n_indexmap[_vertexs[i]] &#061; i;\/\/\u5efa\u7acb\u6620\u5c04<br \/>\n}<br \/>\n_linktable.assign(n, nullptr);<\/p>\n<p>}<br \/>\nint GetVertexIndex(const V&amp; v)<br \/>\n{<br \/>\nauto ret &#061; _indexmap.find(v);<br \/>\nif (ret &#061;&#061; _indexmap.end())return -1;<br \/>\nelse return ret-&gt;second;<br \/>\n}<br \/>\nvoid AddEdge(const V&amp; src, const V&amp; dst, const W&amp; w)<br \/>\n{<\/p>\n<p>int srci &#061; GetVertexIndex(src); \/\/\u6e90\u9876\u70b9\u4e0b\u6807<br \/>\nint dsti &#061; GetVertexIndex(dst); \/\/\u76ee\u6807\u9876\u70b9\u4e0b\u6807<\/p>\n<p>\/\/ \u5934\u63d2\u6cd5&#xff1a;\u65b0\u5efa\u8fb9&#xff0c;\u63d2\u5230srci\u5bf9\u5e94\u7684\u94fe\u8868\u5934\u90e8<br \/>\nEdge* newedge &#061; new Edge(dsti, w);<br \/>\nnewedge-&gt;next &#061; _linktable[srci];<br \/>\n_linktable[srci] &#061; newedge;<\/p>\n<p>\/\/ Direction&#061;false \u65e0\u5411\u56fe&#xff1a;\u53cc\u5411\u90fd\u8981\u52a0\u8fb9<br \/>\nif (Direction &#061;&#061; false)<br \/>\n{<br \/>\nEdge* newedge2 &#061; new Edge(srci, w);<br \/>\nnewedge2-&gt;next &#061; _linktable[dsti];<br \/>\n_linktable[dsti] &#061; newedge2;<br \/>\n}<br \/>\n}<br \/>\nvoid Print()<br \/>\n{<br \/>\n\/\/ \u7b2c\u4e00\u90e8\u5206&#xff1a;\u6253\u5370\u3010\u9876\u70b9\u7f16\u53f7\u548c\u540d\u5b57\u3011<br \/>\nfor (size_t i &#061; 0; i &lt; _vertexs.size(); &#043;&#043;i)<br \/>\n{<br \/>\ncout &lt;&lt; &#034;[&#034; &lt;&lt; i &lt;&lt; &#034;]&#034; &lt;&lt; &#034;-&gt;&#034; &lt;&lt; _vertexs[i] &lt;&lt; endl;<br \/>\n}<br \/>\ncout &lt;&lt; endl;<\/p>\n<p>\/\/ \u7b2c\u4e8c\u90e8\u5206&#xff1a;\u904d\u5386\u90bb\u63a5\u8868 _linktable<br \/>\nfor (size_t i &#061; 0; i &lt; _linktable.size(); &#043;&#043;i)<br \/>\n{<br \/>\n\/\/ \u6253\u5370\u8d77\u70b9&#xff1a;\u9876\u70b9\u540d\u5b57[\u4e0b\u6807]<br \/>\ncout &lt;&lt; _vertexs[i] &lt;&lt; &#034;[&#034; &lt;&lt; i &lt;&lt; &#034;]&#034; &lt;&lt; &#034;-&gt;&#034;;<\/p>\n<p>\/\/ cur\u62ff\u5230\u8fd9\u4e2a\u9876\u70b9\u5bf9\u5e94\u7684\u8fb9\u94fe\u8868\u5934\u6307\u9488<\/p>\n<p>Edge* cur &#061; _linktable[i];<\/p>\n<p>while (cur)<br \/>\n{<br \/>\n\/\/ cur-&gt;_dsti&#xff1a;\u76ee\u6807\u9876\u70b9\u4e0b\u6807<br \/>\n\/\/ _vertexs[cur-&gt;_dsti]&#xff1a;\u76ee\u6807\u9876\u70b9\u540d\u5b57<\/p>\n<p>cout &lt;&lt; _vertexs[cur-&gt;_dsti] &lt;&lt;&#034;[&#034; &lt;&lt; cur-&gt;_dsti &lt;&lt; &#034;]&#034; &lt;&lt; cur-&gt;_w &lt;&lt; &#034;-&gt;&#034;;<br \/>\ncur &#061; cur-&gt;next;<br \/>\n}<br \/>\ncout &lt;&lt; &#034;nullptr&#034; &lt;&lt; endl;<br \/>\n}<br \/>\n}<\/p>\n<p>private:<br \/>\nvector&lt;V&gt;_vertexs;<br \/>\nmap&lt;V, int&gt;_indexmap;<br \/>\nvector&lt;Edge*&gt;_linktable;<br \/>\n}; <\/p>\n<p><span style=\"color:#0d0016\">\u6d4b\u8bd5\u4f8b\u5b50&#xff1a;<\/span><\/p>\n<p>void TestGraph()<br \/>\n{<br \/>\nstring a[] &#061; { &#034;\u5f20\u4e09&#034;, &#034;\u674e\u56db&#034;, &#034;\u738b\u4e94&#034;, &#034;\u8d75\u516d&#034; };<br \/>\nGraph&lt;string, int&gt; g1(a, 4);<br \/>\ng1.AddEdge(&#034;\u5f20\u4e09&#034;, &#034;\u674e\u56db&#034;, 100);<br \/>\ng1.AddEdge(&#034;\u5f20\u4e09&#034;, &#034;\u738b\u4e94&#034;, 200);<br \/>\ng1.AddEdge(&#034;\u738b\u4e94&#034;, &#034;\u8d75\u516d&#034;, 30);<br \/>\ng1.Print();<br \/>\n} <\/p>\n<p><span style=\"color:#0d0016\">\u7ed3\u679c&#xff1a;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"274\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261001021640-6abdc28849287.png\" width=\"679\" \/><\/p>\n<p><span style=\"color:#0d0016\">\u5177\u4f53\u8fc7\u7a0b&#xff1a;<\/span><\/p>\n<p><span style=\"color:#fe2c24\">\u4e0b\u6807&#xff1a;0 \u5f20\u4e09&#xff0c;1 \u674e\u56db&#xff0c;2 \u738b\u4e94&#xff0c;3 \u8d75\u516d<\/span><\/p>\n<\/p>\n<p><span style=\"color:#0d0016\">0.\u6700\u5f00\u59cb<\/span><\/p>\n<p> _linktable[0]: null<br \/>\n_linktable[1]: null<br \/>\n_linktable[2]: null<br \/>\n_linktable[3]: null<\/p>\n<p>1.AddEdge (\u5f20\u4e09&#xff0c;\u674e\u56db&#xff0c;100)<\/p>\n<ul>\n<li>\u7ed9 0 \u53f7&#xff08;\u5f20\u4e09&#xff09;\u94fe\u8868&#xff1a;\u52a0 E1 (\u76ee\u6807 1&#xff0c;\u6743\u91cd 100)<\/li>\n<li>\u7ed9 1 \u53f7&#xff08;\u674e\u56db&#xff09;\u94fe\u8868&#xff1a;\u52a0 E2 (\u76ee\u6807 0&#xff0c;\u6743\u91cd 100)<\/li>\n<\/ul>\n<p> _linktable[0]: E1(1,100) \u2192 null<br \/>\n_linktable[1]: E2(0,100) \u2192 null<br \/>\n_linktable[2]: null<br \/>\n_linktable[3]: null<\/p>\n<p>2.AddEdge (\u5f20\u4e09&#xff0c;\u738b\u4e94&#xff0c;200)<\/p>\n<ul>\n<li>\u7ed9 0 \u53f7&#xff08;\u5f20\u4e09&#xff09;\u94fe\u8868&#xff0c;\u5934\u63d2E3 (\u76ee\u6807 2&#xff0c;\u6743\u91cd 200)&#xff0c;E3 \u8fde\u5728 E1 \u524d\u9762<\/li>\n<li>\u7ed9 2 \u53f7&#xff08;\u738b\u4e94&#xff09;\u94fe\u8868&#xff1a;\u52a0 E4 (\u76ee\u6807 0&#xff0c;\u6743\u91cd 200)<\/li>\n<\/ul>\n<p> _linktable[0]: E3(2,200) \u2192 E1(1,100) \u2192 null<br \/>\n_linktable[1]: E2(0,100) \u2192 null<br \/>\n_linktable[2]: E4(0,200) \u2192 null<br \/>\n_linktable[3]: null<\/p>\n<p>3.AddEdge (\u738b\u4e94&#xff0c;\u8d75\u516d&#xff0c;30)<\/p>\n<ul>\n<li>\u7ed9 2 \u53f7&#xff08;\u738b\u4e94&#xff09;\u94fe\u8868&#xff0c;\u5934\u63d2E5 (\u76ee\u6807 3&#xff0c;\u6743\u91cd 30)&#xff0c;E5 \u8fde\u5728 E4 \u524d\u9762<\/li>\n<li>\u7ed9 3 \u53f7&#xff08;\u8d75\u516d&#xff09;\u94fe\u8868&#xff1a;\u52a0 E6 (\u76ee\u6807 2&#xff0c;\u6743\u91cd 30)<\/li>\n<\/ul>\n<p>\u6700\u7ec8<\/p>\n<p> _linktable[0]: E3(2,200) \u2192 E1(1,100) \u2192 null<br \/>\n_linktable[1]: E2(0,100) \u2192 null<br \/>\n_linktable[2]: E5(3,30) \u2192 E4(0,200) \u2192 null<br \/>\n_linktable[3]: E6(2,30) \u2192 null <\/p>\n<h3><span style=\"color:#0d0016\">\u90bb\u63a5\u77e9\u9635\u548c\u90bb\u63a5\u8868\u5bf9\u6bd4&#xff1a;<\/span><\/h3>\n<ul>\n<li>\u90bb\u63a5\u77e9\u9635&#xff1a;\u67e5\u8fb9\u8d85\u5feb&#xff0c;\u904d\u5386\u90bb\u70b9\u6162&#xff1b;\u7a20\u5bc6\u56fe\u7528&#xff0c;\u9876\u70b9\u4e00\u591a\u7a7a\u95f4\u7206\u70b8\u3002<\/li>\n<li>\u90bb\u63a5\u8868&#xff1a;\u904d\u5386\u90bb\u70b9\u8d85\u5feb&#xff0c;\u67e5\u4e24\u70b9\u4e4b\u95f4\u8fb9\u6162&#xff1b;\u7a00\u758f\u56fe\u7528&#xff0c;\u8282\u7701\u5927\u91cf\u5185\u5b58\u3002<\/li>\n<\/ul>\n<p><span style=\"color:#fe2c24\">\u8fb9\u5c11 &#061; \u7a00\u758f&#xff0c;\u8fb9\u6ee1 &#061; \u7a20\u5bc6\u3002<\/span><\/p>\n<p><span style=\"color:#0d0016\">eg&#xff1a;<\/span><\/p>\n<p>n&#061;1000 \u4e2a\u9876\u70b9<\/p>\n<ul>\n<li>\u90bb\u63a5\u77e9\u9635&#xff1a;\u8981\u5f00 1000\u00d71000 &#061; 100 \u4e07\u7a7a\u95f4&#xff0c;\u5c31\u7b97\u53ea\u6709 10 \u6761\u8fb9&#xff0c;\u4e5f\u8981\u5360\u7528\u8fd9\u4e48\u591a\u5185\u5b58<\/li>\n<li>\u90bb\u63a5\u8868&#xff1a;\u53ea\u5b58\u8fd9 10 \u6761\u8fb9&#xff0c;\u5185\u5b58\u5f00\u9500\u5f88\u5c0f<\/li>\n<\/ul>\n<table>\n<tr>\u5bf9\u6bd4\u9879\u90bb\u63a5\u77e9\u9635\u90bb\u63a5\u8868<\/tr>\n<tbody>\n<tr>\n<td>\u5b58\u50a8\u7ed3\u6784<\/td>\n<td>\u4e8c\u7ef4\u6570\u7ec4 matrix[i][j]matrix[i][j]\u5b58 i\u2192j \u8fb9\u6743&#xff1b;MAX_W \u4ee3\u8868\u65e0\u8fb9<\/td>\n<td>vector&lt;Edge*&gt;\u94fe\u8868\u6570\u7ec4&#xff0c;\u6bcf\u4e2a\u6570\u7ec4\u5143\u7d20\u5c31\u662f\u4e00\u4e2a\u94fe\u8868<\/td>\n<\/tr>\n<tr>\n<td>\u7a7a\u95f4\u590d\u6742\u5ea6<\/td>\n<td>O(n2)\u53ea\u548c\u9876\u70b9\u6570\u6709\u5173&#xff0c;\u548c\u8fb9\u65e0\u5173<\/td>\n<td>O(n&#043;E)\u9876\u70b9 &#043; \u5b9e\u9645\u8fb9&#xff0c;\u8fb9\u8d8a\u5c11\u8d8a\u7701\u7a7a\u95f4<\/td>\n<\/tr>\n<tr>\n<td>\u9002\u5408\u56fe<\/td>\n<td>\u7a20\u5bc6\u56fe&#xff08;\u8fb9\u5f88\u591a&#xff09;<\/td>\n<td>\u7a00\u758f\u56fe&#xff08;\u8fb9\u5f88\u5c11&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u67e5\u8be2 i,j \u4e24\u70b9\u6709\u6ca1\u6709\u8fb9<\/td>\n<td>\u76f4\u63a5matrix[i][j]&#xff0c;O(1)<\/td>\n<td>\u00a0\u9700\u8981\u904d\u5386 i \u7684\u90bb\u63a5\u94fe\u8868&#xff0c;\u6700\u574fO(n)<\/td>\n<\/tr>\n<tr>\n<td>\u904d\u5386\u4e00\u4e2a\u9876\u70b9\u7684\u6240\u6709\u90bb\u8fb9<\/td>\n<td>\u00a0\u8981\u5faa\u73af\u5168\u90e8 n \u4e2a\u70b9&#xff0c;O(n)<\/td>\n<td>\u00a0\u76f4\u63a5\u904d\u5386\u94fe\u8868&#xff0c;\u51fa\u8fb9\u6570\u91cf&#xff0c;\u5f88\u5feb<\/td>\n<\/tr>\n<tr>\n<td>\u65b0\u589e\u8fb9<\/td>\n<td>\u00a0O(1)&#xff0c;\u76f4\u63a5\u8d4b\u503c<\/td>\n<td>\u00a0O(1)&#xff0c;\u5c3e\u63d2\u8282\u70b9<\/td>\n<\/tr>\n<tr>\n<td>\u5220\u9664\u8fb9<\/td>\n<td>\u00a0O(1)&#xff0c;\u76f4\u63a5\u8d4b\u503c MAX_W<\/td>\n<td>\u00a0\u9700\u8981\u904d\u5386\u94fe\u8868\u627e\u5230\u8be5\u8fb9&#xff0c;\u6162<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><span style=\"color:#0d0016\">DFS\u548cBFS&#xff08;\u4ee5\u90bb\u63a5\u77e9\u9635\u5b9e\u73b0&#xff09;<\/span><\/h3>\n<h4><span style=\"color:#0d0016\">BFS:<\/span><\/h4>\n<p>void BFS(const V&amp; v)<br \/>\n{<br \/>\ncout &lt;&lt; &#034;BFS:&#034;;<br \/>\nint srci &#061; GetVertexIndex(v);<br \/>\nif (srci &#061;&#061; -1)<br \/>\n{<br \/>\ncout &lt;&lt; &#034;\u9876\u70b9\u4e0d\u5b58\u5728&#034; &lt;&lt; endl;<br \/>\nreturn;<br \/>\n}<br \/>\nvector&lt;bool&gt;vis(_vertexs.size(), false);<br \/>\nqueue&lt;int&gt;q;\/\/\u5b58\u4e0b\u6807<br \/>\nq.push(srci);<br \/>\nvis[srci] &#061; true;<br \/>\nwhile (q.size())<br \/>\n{<br \/>\nint front &#061; q.front();<br \/>\nq.pop();<br \/>\ncout &lt;&lt; _vertexs[front] &lt;&lt; &#034; &#034;;<br \/>\nfor (int i &#061; 0; i &lt; _vertexs.size(); i&#043;&#043;)\/\/\u628a\u548c\u76f8\u90bb\u7684\u5168\u90e8\u627e\u51fa\u6765<br \/>\n{<br \/>\nif (_matrix[front][i]!&#061;MAX_W &amp;&amp; !vis[i])<br \/>\n{<br \/>\nq.push(i);<br \/>\nvis[i] &#061; true;<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\ncout &lt;&lt; endl;<br \/>\n} <\/p>\n<h4><span style=\"color:#0d0016\">DFS&#xff1a;<\/span><\/h4>\n<p>void DFS(const V&amp;v)<br \/>\n{<br \/>\ncout &lt;&lt; &#034;DFS:&#034;;<br \/>\nint srci &#061; GetVertexIndex(v);<br \/>\nif (srci &#061;&#061; -1)<br \/>\n{<br \/>\ncout &lt;&lt; &#034;\u9876\u70b9\u4e0d\u5b58\u5728&#034; &lt;&lt; endl;<br \/>\nreturn;<br \/>\n}<br \/>\nvector&lt;bool&gt;vis(_vertexs.size(),false);<br \/>\n_dfs(srci, vis);<br \/>\n}<br \/>\nvoid _dfs(int srci, vector&lt;bool&gt;&amp; vis)\/\/\u5f15\u7528vis\u76f8\u5f53\u4e8e\u5168\u5c40<br \/>\n{<br \/>\ncout &lt;&lt; _vertexs[srci] &lt;&lt; &#034; &#034;;<br \/>\nvis[srci] &#061; true;<br \/>\nfor (int i &#061; 0; i&lt; _vertexs.size(); i&#043;&#043;)<br \/>\n{<br \/>\nif (_matrix[srci][i] !&#061; MAX_W &amp;&amp; !vis[i])<br \/>\n{<br \/>\n_dfs(i, vis);<br \/>\n}<br \/>\n}<br \/>\n} <\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#x1f525;keyipatience:\u4e2a\u4eba\u4e3b\u9875 &#x1f3ac;\u4f5c\u8005\u7b80\u4ecb&#xff1a;C\/C\u540e\u7aef\u5f00\u53d1\u5b66\u4e60\u8005 &#x1f31f;\u4e13\u680f\u4f20\u9001\u95e8&#xff1a;\u300ac\u300b\u300alinux\u300b\u300ac\u9ad8\u9636\u6570\u636e\u7ed3\u6784\u300b\u300ac\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u300b \u2b50\ufe0fpatience is key in life \u56fe<br \/>\n\u56fe\u7684\u57fa\u7840\u77e5\u8bc6<br \/>\n1.\u56fe G(V,E)&#xff0c;\u7531\u4e24\u90e8\u5206\u7ec4\u6210<br \/>\nV&#xff08;\u9876\u70b9\u96c6&#xff09;&#xff1a;\u4e00\u5806\u70b9&#xff0c;\u4e0d\u80fd\u4e3a\u7a7aE&#xff08;\u8fb9\u96c6&#xff09;&amp;#xf<\/p>\n","protected":false},"author":2,"featured_media":111505,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[12694,7290,7291,1984,1813],"topic":[],"class_list":["post-111518","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-12694","tag-7290","tag-7291","tag-1984","tag-1813"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u56fe\u89e3\u56fe\u8bba\u6838\u5fc3\uff1a\u4ece\u57fa\u7840\u5230\u90bb\u63a5\u77e9\u9635\uff0c\u90bb\u63a5\u8868\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/111518.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u56fe\u89e3\u56fe\u8bba\u6838\u5fc3\uff1a\u4ece\u57fa\u7840\u5230\u90bb\u63a5\u77e9\u9635\uff0c\u90bb\u63a5\u8868\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"&#x1f525;keyipatience:\u4e2a\u4eba\u4e3b\u9875 &#x1f3ac;\u4f5c\u8005\u7b80\u4ecb&#xff1a;C\/C\u540e\u7aef\u5f00\u53d1\u5b66\u4e60\u8005 &#x1f31f;\u4e13\u680f\u4f20\u9001\u95e8&#xff1a;\u300ac\u300b\u300alinux\u300b\u300ac\u9ad8\u9636\u6570\u636e\u7ed3\u6784\u300b\u300ac\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u300b \u2b50\ufe0fpatience is key in life \u56fe \u56fe\u7684\u57fa\u7840\u77e5\u8bc6 1.\u56fe G(V,E)&#xff0c;\u7531\u4e24\u90e8\u5206\u7ec4\u6210 V&#xff08;\u9876\u70b9\u96c6&#xff09;&#xff1a;\u4e00\u5806\u70b9&#xff0c;\u4e0d\u80fd\u4e3a\u7a7aE&#xff08;\u8fb9\u96c6&#xff09;&amp;#xf\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/111518.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-01T02:16:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261001021635-6abdc28359edf.jpg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/111518.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/111518.html\",\"name\":\"\u56fe\u89e3\u56fe\u8bba\u6838\u5fc3\uff1a\u4ece\u57fa\u7840\u5230\u90bb\u63a5\u77e9\u9635\uff0c\u90bb\u63a5\u8868\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-01T02:16:41+00:00\",\"dateModified\":\"2026-10-01T02:16:41+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/111518.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/111518.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/111518.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u56fe\u89e3\u56fe\u8bba\u6838\u5fc3\uff1a\u4ece\u57fa\u7840\u5230\u90bb\u63a5\u77e9\u9635\uff0c\u90bb\u63a5\u8868\u5b9e\u73b0\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u56fe\u89e3\u56fe\u8bba\u6838\u5fc3\uff1a\u4ece\u57fa\u7840\u5230\u90bb\u63a5\u77e9\u9635\uff0c\u90bb\u63a5\u8868\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/111518.html","og_locale":"zh_CN","og_type":"article","og_title":"\u56fe\u89e3\u56fe\u8bba\u6838\u5fc3\uff1a\u4ece\u57fa\u7840\u5230\u90bb\u63a5\u77e9\u9635\uff0c\u90bb\u63a5\u8868\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"&#x1f525;keyipatience:\u4e2a\u4eba\u4e3b\u9875 &#x1f3ac;\u4f5c\u8005\u7b80\u4ecb&#xff1a;C\/C\u540e\u7aef\u5f00\u53d1\u5b66\u4e60\u8005 &#x1f31f;\u4e13\u680f\u4f20\u9001\u95e8&#xff1a;\u300ac\u300b\u300alinux\u300b\u300ac\u9ad8\u9636\u6570\u636e\u7ed3\u6784\u300b\u300ac\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u300b \u2b50\ufe0fpatience is key in life \u56fe \u56fe\u7684\u57fa\u7840\u77e5\u8bc6 1.\u56fe G(V,E)&#xff0c;\u7531\u4e24\u90e8\u5206\u7ec4\u6210 V&#xff08;\u9876\u70b9\u96c6&#xff09;&#xff1a;\u4e00\u5806\u70b9&#xff0c;\u4e0d\u80fd\u4e3a\u7a7aE&#xff08;\u8fb9\u96c6&#xff09;&amp;#xf","og_url":"https:\/\/www.wsisp.com\/helps\/111518.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-01T02:16:41+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261001021635-6abdc28359edf.jpg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"11 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/111518.html","url":"https:\/\/www.wsisp.com\/helps\/111518.html","name":"\u56fe\u89e3\u56fe\u8bba\u6838\u5fc3\uff1a\u4ece\u57fa\u7840\u5230\u90bb\u63a5\u77e9\u9635\uff0c\u90bb\u63a5\u8868\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-01T02:16:41+00:00","dateModified":"2026-10-01T02:16:41+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/111518.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/111518.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/111518.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u56fe\u89e3\u56fe\u8bba\u6838\u5fc3\uff1a\u4ece\u57fa\u7840\u5230\u90bb\u63a5\u77e9\u9635\uff0c\u90bb\u63a5\u8868\u5b9e\u73b0"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/111518","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=111518"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/111518\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/111505"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=111518"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=111518"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=111518"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=111518"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}