{"id":160,"date":"2019-12-28T08:15:00","date_gmt":"2019-12-28T08:15:00","guid":{"rendered":"https:\/\/imwarming.com\/?p=160"},"modified":"2019-12-28T08:15:00","modified_gmt":"2019-12-28T08:15:00","slug":"%e9%82%bb%e6%8e%a5%e7%9f%a9%e9%98%b5","status":"publish","type":"post","link":"https:\/\/imwarming.com\/?p=160","title":{"rendered":"\u90bb\u63a5\u77e9\u9635"},"content":{"rendered":"<div class=\"cnblogs_code\">\n<pre>#include&lt;bits\/stdc++.h&gt;\n<span style=\"color: #0000ff;\">#define<\/span> maxvertexnum 100 <span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">\u6700\u5927\u9876\u70b9<\/span>\n<span style=\"color: #0000ff;\">#define<\/span> infinity 65535 <span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\"> &infin;\u8bbe\u4e3a\u53cc\u5b57\u8282\u65e0\u7b26\u53f7\u6574\u6570\u7684\u6700\u5927\u503c65535<\/span>\n<span style=\"color: #0000ff;\">using<\/span> <span style=\"color: #0000ff;\">namespace<\/span><span style=\"color: #000000;\"> std;\n\ntypedef <\/span><span style=\"color: #0000ff;\">int<\/span> vertex; <span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">\u7528\u9876\u70b9\u4e0b\u6807\u8868\u793a\u9876\u70b9,\u4e3a\u6574\u578b<\/span>\ntypedef <span style=\"color: #0000ff;\">int<\/span> weighttype; <span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">\u8fb9\u7684\u6743\u503c<\/span>\ntypedef <span style=\"color: #0000ff;\">char<\/span> datatype; <span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">\u9876\u70b9\u50a8\u5b58\u7684\u6570\u636e\u7c7b\u578b<\/span>\ntypedef <span style=\"color: #0000ff;\">struct<\/span> enode *<span style=\"color: #000000;\">ptrtoenode;\n<\/span><span style=\"color: #0000ff;\">struct<\/span><span style=\"color: #000000;\"> enode{\n    vertex v1,v2; <\/span><span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">\u6709\u5411\u8fb9&lt;v1,v2&gt;<\/span>\n    weighttype weight; <span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">\u6743\u91cd<\/span>\n<span style=\"color: #000000;\">};\ntypedef prttoenode edge; <\/span><span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">\u56fe\u7ed3\u70b9\u7684\u5b9a\u4e49<\/span>\ntypedef gnode *<span style=\"color: #000000;\">ptrtognode;\n<\/span><span style=\"color: #0000ff;\">struct<\/span><span style=\"color: #000000;\"> gnode{\n    <\/span><span style=\"color: #0000ff;\">int<\/span> nv; <span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">\u9876\u70b9\u6570<\/span>\n    <span style=\"color: #0000ff;\">int<\/span> ne; <span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">\u8fb9\u6570<\/span>\n    weighttype g[maxvertexnum][maxvertexnum]; <span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">\u90bb\u63a5\u77e9\u9635<\/span>\n    datatype data[maxvertexnum]; <span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">\u5b58\u9876\u70b9\u7684\u6570\u636e\n    <\/span><span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">\u6ce8\u610f\uff1a\u5f88\u591a\u60c5\u51b5\u4e0b\uff0c\u9876\u70b9\u65e0\u6570\u636e\uff0c\u6b64\u65f6data[]\u53ef\u4ee5\u4e0d\u7528\u51fa\u73b0<\/span>\n<span style=\"color: #000000;\">};\ntypedef ptrtognode mgraph; <\/span><span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">\u4ee5\u90bb\u63a5\u77e9\u9635\u5b58\u50a8\u7684\u56fe\u7c7b\u578b<\/span>\nmgraph creatgraph(<span style=\"color: #0000ff;\">int<\/span><span style=\"color: #000000;\"> vertexnum){\n    <\/span><span style=\"color: #008000;\">\/*<\/span><span style=\"color: #008000;\"> \u521d\u59cb\u5316\u4e00\u4e2a\u6709vertexnum\u4e2a\u9876\u70b9\u4f46\u6ca1\u6709\u8fb9\u7684\u56fe <\/span><span style=\"color: #008000;\">*\/<\/span><span style=\"color: #000000;\">\n    vertex v,w;\n    mgraph graph;\n    graph <\/span>= (mgraph)<span style=\"color: #0000ff;\">malloc<\/span>(<span style=\"color: #0000ff;\">sizeof<\/span>(<span style=\"color: #0000ff;\">struct<\/span><span style=\"color: #000000;\"> gnode));\n    graph<\/span>-&gt;nv =<span style=\"color: #000000;\"> vertexnum;\n    graph<\/span>-&gt;ne = <span style=\"color: #800080;\">0<\/span>;<span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">\u521d\u59cb\u5316\u90bb\u63a5\u77e9\u9635\uff0c\u8fd9\u91cc\u9ed8\u8ba4\u9876\u70b9\u7f16\u53f7\u4ece0\u5f00\u59cb\uff0c\u5230(graph-&gt;nv-1)<\/span>\n    <span style=\"color: #0000ff;\">for<\/span>(v = <span style=\"color: #800080;\">0<\/span>; v&lt;graph-&gt;nv; v++<span style=\"color: #000000;\">){\n        <\/span><span style=\"color: #0000ff;\">for<\/span>(w = <span style=\"color: #800080;\">0<\/span>; w&lt;graph-&gt;nv; w++<span style=\"color: #000000;\">){\n            graph<\/span>-&gt;g[v][w] =<span style=\"color: #000000;\"> infinity;\n        }\n    }\n    <\/span><span style=\"color: #0000ff;\">return<\/span><span style=\"color: #000000;\"> graph;\n}\n\n<\/span><span style=\"color: #0000ff;\">void<\/span><span style=\"color: #000000;\"> insertedge(mgraph graph,edge e){\n    <\/span><span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">\u63d2\u5165\u8fb9&lt;v1,v2&gt;<\/span>\n    graph-&gt;g[e-&gt;v1][e-&gt;v2] = e-&gt;<span style=\"color: #000000;\">weight; \n    <\/span><span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">\u82e5\u662f\u65e0\u5411\u56fe\uff0c\u8fd8\u8981\u63d2\u5165\u8fb9&lt;v1,v2&gt;\n    <\/span><span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">graph-&gt;g[e-&gt;v2][e-&gt;v1] = e-&gt;weight;<\/span>\n<span style=\"color: #000000;\">}\n\nmgraph buildgraph(){\n    mgraph graph;\n    edge e;\n    vertex v;\n    <\/span><span style=\"color: #0000ff;\">int<\/span><span style=\"color: #000000;\"> nv,i;\n    scanf(<\/span><span style=\"color: #800000;\">\"<\/span><span style=\"color: #800000;\">%d<\/span><span style=\"color: #800000;\">\"<\/span>,&amp;nv);<span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">\u8bfb\u5165\u9876\u70b9\u4e2a\u6570<\/span>\n    graph = creatgraph(nv);<span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">\u521d\u59cb\u5316\u6709nv\u4e2a\u9876\u70b9\u4f46\u6ca1\u6709\u8fb9\u7684\u56fe<\/span>\n    scanf(<span style=\"color: #800000;\">\"<\/span><span style=\"color: #800000;\">%d<\/span><span style=\"color: #800000;\">\"<\/span>,&amp;(graph-&gt;ne));<span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">\u8fb9\u6570<\/span>\n    <span style=\"color: #0000ff;\">if<\/span>(graph-&gt;ne != <span style=\"color: #800080;\">0<\/span><span style=\"color: #000000;\">){\n        e <\/span>= (edge)<span style=\"color: #0000ff;\">malloc<\/span>(<span style=\"color: #0000ff;\">sizeof<\/span>(<span style=\"color: #0000ff;\">struct<\/span><span style=\"color: #000000;\"> enode));\n        <\/span><span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">\u5efa\u7acb\u8fb9\u7ed3\u70b9\uff0c\u8bfb\u5165\u8fb9\uff0c\u683c\u5f0f\u5316\u4e3a&ldquo;\u8d77\u70b9 \u7ec8\u70b9 \u6743\u91cd&rdquo;\uff0c\u63d2\u5165\u90bb\u63a5\u77e9\u9635<\/span>\n        <span style=\"color: #0000ff;\">for<\/span>(i = <span style=\"color: #800080;\">0<\/span>; i&lt;graph-&gt;ne; i++<span style=\"color: #000000;\">){\n            scanf(<\/span><span style=\"color: #800000;\">\"<\/span><span style=\"color: #800000;\">%d %d %d<\/span><span style=\"color: #800000;\">\"<\/span>,&amp;e-&gt;v1,&amp;e-&gt;v2,&amp;e-&gt;<span style=\"color: #000000;\">weight);\n            <\/span><span style=\"color: #008000;\">\/\/<\/span><span style=\"color: #008000;\">\u6ce8\u610f\u5982\u679c\u6743\u91cd\u4e0d\u662f\u6574\u578b\uff0c%d\u8981\u6539<\/span>\n<span style=\"color: #000000;\">            insertedge(graph , e);\n        }\n    }\n    <\/span><span style=\"color: #0000ff;\">for<\/span>(v = <span style=\"color: #800080;\">0<\/span>; v&lt;graph-&gt;nv; v++<span style=\"color: #000000;\">){\n        scanf(<\/span><span style=\"color: #800000;\">\"<\/span><span style=\"color: #800000;\">%c<\/span><span style=\"color: #800000;\">\"<\/span>,&amp;(graph-&gt;<span style=\"color: #000000;\">data[v]));\n    }\n    <\/span><span style=\"color: #0000ff;\">return<\/span><span style=\"color: #000000;\"> graph;\n}<\/span><\/pre>\n<\/div>\n<p>\u90bb\u63a5\u77e9\u9635<\/p>\n","protected":false},"excerpt":{"rendered":"<p>#include&lt;bits\/stdc++.h&gt; #define maxvertexnum [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-160","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v18.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u90bb\u63a5\u77e9\u9635 - imwarming<\/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:\/\/imwarming.com\/?p=160\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u90bb\u63a5\u77e9\u9635 - imwarming\" \/>\n<meta property=\"og:description\" content=\"#include&lt;bits\/stdc++.h&gt; #define maxvertexnum [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/imwarming.com\/?p=160\" \/>\n<meta property=\"og:site_name\" content=\"imwarming\" \/>\n<meta property=\"article:published_time\" content=\"2019-12-28T08:15:00+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"warming\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/imwarming.com\/#website\",\"url\":\"https:\/\/imwarming.com\/\",\"name\":\"imwarming\",\"description\":\"\u6c38\u8fdc\u5e74\u8f7b\uff0c\u6c38\u8fdc\u70ed\u6cea\u76c8\u7736\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/imwarming.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/imwarming.com\/?p=160#webpage\",\"url\":\"https:\/\/imwarming.com\/?p=160\",\"name\":\"\u90bb\u63a5\u77e9\u9635 - imwarming\",\"isPartOf\":{\"@id\":\"https:\/\/imwarming.com\/#website\"},\"datePublished\":\"2019-12-28T08:15:00+00:00\",\"dateModified\":\"2019-12-28T08:15:00+00:00\",\"author\":{\"@id\":\"https:\/\/imwarming.com\/#\/schema\/person\/9d76869a558bac6dd0d6d58f420ee8ea\"},\"breadcrumb\":{\"@id\":\"https:\/\/imwarming.com\/?p=160#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/imwarming.com\/?p=160\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/imwarming.com\/?p=160#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/imwarming.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u90bb\u63a5\u77e9\u9635\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/imwarming.com\/#\/schema\/person\/9d76869a558bac6dd0d6d58f420ee8ea\",\"name\":\"warming\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/imwarming.com\/#personlogo\",\"inLanguage\":\"zh-Hans\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c4a913eed88f7601b76bbf2b103472621195b6fa2f742af89b5ea185b60e7cff?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c4a913eed88f7601b76bbf2b103472621195b6fa2f742af89b5ea185b60e7cff?s=96&d=mm&r=g\",\"caption\":\"warming\"},\"sameAs\":[\"https:\/\/imwarming.com\"],\"url\":\"https:\/\/imwarming.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u90bb\u63a5\u77e9\u9635 - imwarming","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:\/\/imwarming.com\/?p=160","og_locale":"zh_CN","og_type":"article","og_title":"\u90bb\u63a5\u77e9\u9635 - imwarming","og_description":"#include&lt;bits\/stdc++.h&gt; #define maxvertexnum [&hellip;]","og_url":"https:\/\/imwarming.com\/?p=160","og_site_name":"imwarming","article_published_time":"2019-12-28T08:15:00+00:00","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"warming","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/imwarming.com\/#website","url":"https:\/\/imwarming.com\/","name":"imwarming","description":"\u6c38\u8fdc\u5e74\u8f7b\uff0c\u6c38\u8fdc\u70ed\u6cea\u76c8\u7736","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/imwarming.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"WebPage","@id":"https:\/\/imwarming.com\/?p=160#webpage","url":"https:\/\/imwarming.com\/?p=160","name":"\u90bb\u63a5\u77e9\u9635 - imwarming","isPartOf":{"@id":"https:\/\/imwarming.com\/#website"},"datePublished":"2019-12-28T08:15:00+00:00","dateModified":"2019-12-28T08:15:00+00:00","author":{"@id":"https:\/\/imwarming.com\/#\/schema\/person\/9d76869a558bac6dd0d6d58f420ee8ea"},"breadcrumb":{"@id":"https:\/\/imwarming.com\/?p=160#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/imwarming.com\/?p=160"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/imwarming.com\/?p=160#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/imwarming.com\/"},{"@type":"ListItem","position":2,"name":"\u90bb\u63a5\u77e9\u9635"}]},{"@type":"Person","@id":"https:\/\/imwarming.com\/#\/schema\/person\/9d76869a558bac6dd0d6d58f420ee8ea","name":"warming","image":{"@type":"ImageObject","@id":"https:\/\/imwarming.com\/#personlogo","inLanguage":"zh-Hans","url":"https:\/\/secure.gravatar.com\/avatar\/c4a913eed88f7601b76bbf2b103472621195b6fa2f742af89b5ea185b60e7cff?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c4a913eed88f7601b76bbf2b103472621195b6fa2f742af89b5ea185b60e7cff?s=96&d=mm&r=g","caption":"warming"},"sameAs":["https:\/\/imwarming.com"],"url":"https:\/\/imwarming.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/imwarming.com\/index.php?rest_route=\/wp\/v2\/posts\/160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/imwarming.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/imwarming.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/imwarming.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/imwarming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=160"}],"version-history":[{"count":0,"href":"https:\/\/imwarming.com\/index.php?rest_route=\/wp\/v2\/posts\/160\/revisions"}],"wp:attachment":[{"href":"https:\/\/imwarming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/imwarming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/imwarming.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}