{"id":304487,"date":"2020-05-29T09:00:45","date_gmt":"2020-05-29T09:00:45","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=304487"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=304487","title":{"rendered":"\u041e\u0431\u0445\u043e\u0434 \u0433\u0440\u0430\u0444\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438: \u043f\u043e\u0438\u0441\u043a \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u0438 \u043f\u043e\u0438\u0441\u043a \u0432 \u0448\u0438\u0440\u0438\u043d\u0443 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 JavaScript"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/504374\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/_f\/kf\/kl\/_fkfkl3gfkmnwtes2eypbueifxe.png\"><\/p>\n<p>  \u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a.<\/p>\n<p>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/medium.com\/@trykv\/algorithms-on-graphs-lets-talk-depth-first-search-dfs-and-breadth-first-search-bfs-5250c31d831a\" rel=\"nofollow\">\u00abAlgorithms on Graphs: Let\u2019s talk Depth-First Search (DFS) and Breadth-First Search (BFS)\u00bb<\/a> \u0430\u0432\u0442\u043e\u0440\u0430 Try Khov.<\/p>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043e\u0431\u0445\u043e\u0434 \u0433\u0440\u0430\u0444\u0430?<\/h3>\n<p>  \u041f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043e\u0431\u0445\u043e\u0434 \u0433\u0440\u0430\u0444\u0430 \u2014 \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043e\u0442 \u043e\u0434\u043d\u043e\u0439 \u0435\u0433\u043e \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u043a \u0434\u0440\u0443\u0433\u043e\u0439 \u0432 \u043f\u043e\u0438\u0441\u043a\u0430\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0441\u0432\u044f\u0437\u0435\u0439 \u044d\u0442\u0438\u0445 \u0432\u0435\u0440\u0448\u0438\u043d. \u0421\u0432\u044f\u0437\u0438 (\u043b\u0438\u043d\u0438\u0438, \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u044e\u0449\u0438\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b) \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438, \u043f\u0443\u0442\u044f\u043c\u0438, \u0433\u0440\u0430\u043d\u044f\u043c\u0438 \u0438\u043b\u0438 \u0440\u0435\u0431\u0440\u0430\u043c\u0438 \u0433\u0440\u0430\u0444\u0430. \u0412\u0435\u0440\u0448\u0438\u043d\u044b \u0433\u0440\u0430\u0444\u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u043d\u0443\u044e\u0442\u0441\u044f \u0443\u0437\u043b\u0430\u043c\u0438.<\/p>\n<p>  \u0414\u0432\u0443\u043c\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c\u0438 \u043e\u0431\u0445\u043e\u0434\u0430 \u0433\u0440\u0430\u0444\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0438\u0441\u043a \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0443 (Depth-First Search, DFS) \u0438 \u043f\u043e\u0438\u0441\u043a \u0432 \u0448\u0438\u0440\u0438\u043d\u0443 (Breadth-First Search, BFS).<\/p>\n<p>  \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043e\u0431\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u0445\u043e\u0434\u0430 \u0433\u0440\u0430\u0444\u0430, \u043e\u043d\u0438 \u0438\u043c\u0435\u044e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u044f. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 DFS.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3>\u041f\u043e\u0438\u0441\u043a \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0443<\/h3>\n<p>  DFS \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u00ab\u043f\u043e\u0433\u0440\u0443\u0436\u0430\u0439\u0441\u044f \u0433\u043b\u0443\u0431\u0436\u0435, \u0433\u043e\u043b\u043e\u0432\u043e\u0439 \u0432\u043f\u0435\u0440\u0435\u0434\u00bb (\u00abgo deep, head first\u00bb). \u0418\u0434\u0435\u044f \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u0434\u0432\u0438\u0433\u0430\u0435\u043c\u0441\u044f \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b (\u0442\u043e\u0447\u043a\u0438, \u043c\u0435\u0441\u0442\u0430) \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 (\u043f\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438) \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0435\u043c \u043a\u043e\u043d\u0446\u0430 \u043f\u0443\u0442\u0438 \u0438\u043b\u0438 \u043f\u0443\u043d\u043a\u0442\u0430 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f (\u0438\u0441\u043a\u043e\u043c\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b). \u0415\u0441\u043b\u0438 \u043c\u044b \u0434\u043e\u0441\u0442\u0438\u0433\u043b\u0438 \u043a\u043e\u043d\u0446\u0430 \u043f\u0443\u0442\u0438, \u043d\u043e \u043e\u043d \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0443\u043d\u043a\u0442\u043e\u043c \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0442\u043e \u043c\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043d\u0430\u0437\u0430\u0434 (\u043a \u0442\u043e\u0447\u043a\u0435 \u0440\u0430\u0437\u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0440\u0430\u0441\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043f\u0443\u0442\u0435\u0439) \u0438 \u0438\u0434\u0435\u043c \u043f\u043e \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0443.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/-d\/dk\/wt\/-ddkwtwgddcvzo4mbrpzeiaklm8.png\"><\/p>\n<p>  \u041c\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u0432 \u0442\u043e\u0447\u043a\u0435 \u00abs\u00bb \u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u00abt\u00bb. \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u044f DFS, \u043c\u044b \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u043e\u0434\u0438\u043d \u0438\u0437 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043f\u0443\u0442\u0435\u0439, \u0434\u0432\u0438\u0433\u0430\u0435\u043c\u0441\u044f \u043f\u043e \u043d\u0435\u043c\u0443 \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u0438, \u0435\u0441\u043b\u0438 \u043d\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b\u0438 t, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u0438 \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0443\u0442\u044c. \u0412\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/gd\/v-\/-1\/gdv--18wxok-yjflx_zjlwktysi.png\"><\/p>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0434\u0432\u0438\u0433\u0430\u0435\u043c\u0441\u044f \u043f\u043e \u043f\u0443\u0442\u0438 (p1) \u043a \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u0435 \u0438 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u043a\u043e\u043d\u0435\u0446 \u043f\u0443\u0442\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u0435.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/6q\/ia\/h-\/6qiah-iw-qpybs2fdw072vuvrna.png\"><\/p>\n<p>  \u041c\u044b \u0434\u043e\u0441\u0442\u0438\u0433\u043b\u0438 \u043a\u043e\u043d\u0446\u0430 p1, \u043d\u043e \u043d\u0435 \u043d\u0430\u0448\u043b\u0438 t, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u0432 s \u0438 \u0434\u0432\u0438\u0433\u0430\u0435\u043c\u0441\u044f \u043f\u043e \u0432\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0443\u0442\u0438.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ck\/ui\/ad\/ckuiadguztc8gx3r6gigroyum_a.png\"><\/p>\n<p>  \u0414\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0432 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0439 \u043a \u0442\u043e\u0447\u043a\u0435 \u00abs\u00bb \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u043f\u0443\u0442\u0438 \u00abp2\u00bb \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0442\u0440\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0435\u0440\u0448\u0438\u043d\u0443, \u0432\u0435\u043d\u0447\u0430\u044e\u0449\u0443\u044e \u043f\u0435\u0440\u0432\u043e\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u043c\u044b \u0443\u0436\u0435 \u043f\u043e\u0441\u0435\u0449\u0430\u043b\u0438, \u0442\u043e \u0434\u0432\u0438\u0433\u0430\u0435\u043c\u0441\u044f \u043f\u043e \u0432\u0442\u043e\u0440\u043e\u043c\u0443.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/1h\/yz\/7o\/1hyz7ojpnp__g0w9sg5kr9bzeyk.png\"><\/p>\n<p>  \u041c\u044b \u0432\u043d\u043e\u0432\u044c \u0434\u043e\u0441\u0442\u0438\u0433\u043b\u0438 \u043a\u043e\u043d\u0446\u0430 \u043f\u0443\u0442\u0438, \u043d\u043e \u043d\u0435 \u043d\u0430\u0448\u043b\u0438 t, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043d\u0430\u0437\u0430\u0434. \u0421\u043b\u0435\u0434\u0443\u0435\u043c \u043f\u043e \u0442\u0440\u0435\u0442\u044c\u0435\u043c\u0443 \u043f\u0443\u0442\u0438 \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u043c \u0438\u0441\u043a\u043e\u043c\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u00abt\u00bb.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/oy\/4d\/mm\/oy4dmm-velx-yladbqyvyqrbkts.png\"><\/p>\n<p>  \u0422\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 DFS. \u0414\u0432\u0438\u0433\u0430\u0435\u043c\u0441\u044f \u043f\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 \u0434\u043e \u043a\u043e\u043d\u0446\u0430. \u0415\u0441\u043b\u0438 \u043a\u043e\u043d\u0435\u0446 \u043f\u0443\u0442\u0438 \u2014 \u044d\u0442\u043e \u0438\u0441\u043a\u043e\u043c\u0430\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u0430, \u043c\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438. \u0415\u0441\u043b\u0438 \u043d\u0435\u0442, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043d\u0430\u0437\u0430\u0434 \u0438 \u0434\u0432\u0438\u0433\u0430\u0435\u043c\u0441\u044f \u043f\u043e \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0432\u0441\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b.<\/p>\n<p>  \u041c\u044b \u0441\u043b\u0435\u0434\u0443\u0435\u043c \u044d\u0442\u043e\u043c\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u0435.<\/p>\n<p>  \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430.<\/p>\n<p>  \u0412\u043e\u0442 JavaScript-\u043a\u043e\u0434:<\/p>\n<pre><code class=\"javascript\">\/\/ \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438, \u0447\u0442\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0434\u0435\u043b\u043e \u0441\u043e \u0441\u043c\u0435\u0436\u043d\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c \/\/ \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a\u0438\u043c: adj = {A: [B,C], B:[D,F], ... } function dfs(adj, v, t) { \t\/\/ adj - \u0441\u043c\u0435\u0436\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \t\/\/ v - \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u043d\u044b\u0439 \u0443\u0437\u0435\u043b (\u0432\u0435\u0440\u0448\u0438\u043d\u0430) \t\/\/ t - \u043f\u0443\u043d\u043a\u0442 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f  \t\/\/ \u044d\u0442\u043e \u043e\u0431\u0449\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0438 \t\/\/ \u043b\u0438\u0431\u043e \u0434\u043e\u0441\u0442\u0438\u0433\u043b\u0438 \u043f\u0443\u043d\u043a\u0442\u0430 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043b\u0438\u0431\u043e \u0443\u0436\u0435 \u043f\u043e\u0441\u0435\u0449\u0430\u043b\u0438 \u0443\u0437\u0435\u043b \tif(v === t) return true \tif(v.visited) return false  \t\/\/ \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u043c \u0443\u0437\u0435\u043b \u043a\u0430\u043a \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u043d\u044b\u0439 \tv.visited = true \t\/\/ \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0432\u0441\u0435\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 (\u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0435 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b) v \tfor(let neighbor of adj[v]) { \t\t\/\/ \u0435\u0441\u043b\u0438 \u0441\u043e\u0441\u0435\u0434 \u043d\u0435 \u043f\u043e\u0441\u0435\u0449\u0430\u043b\u0441\u044f \t\tif(!neighbor.visited) { \t\t\t\/\/ \u0434\u0432\u0438\u0433\u0430\u0435\u043c\u0441\u044f \u043f\u043e \u043f\u0443\u0442\u0438 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u043d\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u043b\u0438 \u043b\u0438 \u043c\u044b \u043f\u0443\u043d\u043a\u0442\u0430 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \t\t\tlet reached = dfs(adj, neighbor, t) \t\t\t\/\/ \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c true, \u0435\u0441\u043b\u0438 \u0434\u043e\u0441\u0442\u0438\u0433\u043b\u0438 \t\t\tif(reached) return true \t\t} \t} \t\/\/ \u0435\u0441\u043b\u0438 \u043e\u0442 v \u0434\u043e t \u0434\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \treturn false } <\/code><\/pre>\n<p>  \u0417\u0430\u043c\u0435\u0442\u043a\u0430: \u044d\u0442\u043e\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 DFS-\u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0434\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u0435. DFS \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0446\u0435\u043b\u044f\u0445. \u041e\u0442 \u044d\u0442\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u0442\u043e, \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u0430\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043e\u0431\u0449\u0430\u044f \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a.<\/p>\n<h4>\u0410\u043d\u0430\u043b\u0438\u0437 DFS<\/h4>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u044d\u0442\u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u043e\u0431\u0445\u043e\u0434\u0438\u043c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u00ab\u0441\u043e\u0441\u0435\u0434\u0430\u00bb \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0437\u043b\u0430, \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044f \u0442\u0435\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0441\u0435\u0449\u0430\u043b\u0438 \u0440\u0430\u043d\u0435\u0435, \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0440\u0430\u0432\u043d\u043e\u0435 O(V + E).<\/p>\n<p>  \u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 V+E:<\/p>\n<p>  V \u2014 \u043e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0435\u0440\u0448\u0438\u043d. E \u2014 \u043e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0433\u0440\u0430\u043d\u0435\u0439 (\u0440\u0435\u0431\u0435\u0440).<\/p>\n<p>  \u041c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c V*E, \u043e\u0434\u043d\u0430\u043a\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0434\u0443\u043c\u0430\u0435\u043c, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 V*E.<\/p>\n<p>  V*E \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u0435, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0433\u0440\u0430\u043d\u0438 \u0433\u0440\u0430\u0444\u0430 \u0431\u0435\u0437\u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u044d\u0442\u0438\u0445 \u0433\u0440\u0430\u043d\u0435\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u0435.<\/p>\n<p>  \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, V+E \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u043c\u044b \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u043c \u043b\u0438\u0448\u044c \u043f\u0440\u0438\u043c\u044b\u043a\u0430\u044e\u0449\u0438\u0435 \u043a \u043d\u0435\u0439 \u0433\u0440\u0430\u043d\u0438. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043a\u0430\u0436\u0434\u0430\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u0438\u043c\u0435\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0433\u0440\u0430\u043d\u0435\u0439 \u0438, \u0432 \u0445\u0443\u0434\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043c\u044b \u043e\u0431\u043e\u0439\u0434\u0435\u043c \u0432\u0441\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b (O(V)) \u0438 \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0432\u0441\u0435 \u0433\u0440\u0430\u043d\u0438 (O(E)). \u041c\u044b \u0438\u043c\u0435\u0435\u043c V \u0432\u0435\u0440\u0448\u0438\u043d \u0438 E \u0433\u0440\u0430\u043d\u0435\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c V+E.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044e \u0434\u043b\u044f \u043e\u0431\u0445\u043e\u0434\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b, \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0442\u0435\u043a (\u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043e\u0448\u0438\u0431\u043a\u0435 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0435\u043a\u0430). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 O(V).<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c BFS.<\/p>\n<h3>\u041f\u043e\u0438\u0441\u043a \u0432 \u0448\u0438\u0440\u0438\u043d\u0443<\/h3>\n<p>  BFS \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u00ab\u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0439\u0441\u044f, \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u044f\u0441\u044c \u043d\u0430 \u0432\u044b\u0441\u043e\u0442\u0443 \u043f\u0442\u0438\u0447\u044c\u0435\u0433\u043e \u043f\u043e\u043b\u0435\u0442\u0430\u00bb (\u00abgo wide, bird\u2019s eye-view\u00bb). \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 \u0434\u043e \u043a\u043e\u043d\u0446\u0430, BFS \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u0432\u043f\u0435\u0440\u0435\u0434 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0441\u043e\u0441\u0435\u0434\u0443 \u0437\u0430 \u0440\u0430\u0437. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/-d\/dk\/wt\/-ddkwtwgddcvzo4mbrpzeiaklm8.png\"><\/p>\n<p>  \u0412\u043c\u0435\u0441\u0442\u043e \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u043f\u0443\u0442\u0438, BFS \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442 \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0435 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u043a s \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0437\u0430 \u043e\u0434\u043d\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 (\u0448\u0430\u0433), \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0438 \u0442\u0430\u043a \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043e t.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/1u\/vb\/ny\/1uvbnygi83vt6bxqnmv1hbwuzyq.png\"><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/tg\/en\/jq\/tgenjqvsz1zipcv3obsicrhq78a.png\"><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/tf\/j9\/on\/tfj9on04zudfmelpbn00xeh_tpm.png\"><\/p>\n<p>  \u0427\u0435\u043c DFS \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 BFS? \u041c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0434\u0443\u043c\u0430\u0442\u044c, \u0447\u0442\u043e DFS \u0438\u0434\u0435\u0442 \u043d\u0430\u043f\u0440\u043e\u043b\u043e\u043c, \u0430 BFS \u043d\u0435 \u0442\u043e\u0440\u043e\u043f\u0438\u0442\u0441\u044f, \u0430 \u0438\u0437\u0443\u0447\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043e\u0434\u043d\u043e\u0433\u043e \u0448\u0430\u0433\u0430.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441: \u043a\u0430\u043a \u0443\u0437\u043d\u0430\u0442\u044c, \u043a\u0430\u043a\u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u043c\u0438?<\/p>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0435\u0439 \u00ab\u043f\u0435\u0440\u0432\u044b\u043c \u0432\u043e\u0448\u0435\u043b, \u043f\u0435\u0440\u0432\u044b\u043c \u0432\u044b\u0448\u0435\u043b\u00bb (first-in-first-out, FIFO) \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 (queue). \u041c\u044b \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0443\u044e \u043a \u043d\u0430\u043c \u0432\u0435\u0440\u0448\u0438\u043d\u0443, \u0437\u0430\u0442\u0435\u043c \u0435\u0435 \u043d\u0435\u043f\u043e\u0441\u0435\u0449\u0435\u043d\u043d\u044b\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439, \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u043f\u043e\u043a\u0430 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0435 \u043e\u043f\u0443\u0441\u0442\u0435\u0435\u0442 \u0438\u043b\u0438 \u043f\u043e\u043a\u0430 \u043c\u044b \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043c \u0438\u0441\u043a\u043e\u043c\u0443\u044e \u0432\u0435\u0440\u0448\u0438\u043d\u0443.<\/p>\n<p>  \u0412\u043e\u0442 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"javascript\">\/\/ \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438, \u0447\u0442\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0434\u0435\u043b\u043e \u0441\u043e \u0441\u043c\u0435\u0436\u043d\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c \/\/ \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a\u0438\u043c: adj = {A:[B,C,D], B:[E,F], ... } function bfs(adj, s, t) { \t\/\/ adj - \u0441\u043c\u0435\u0436\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \t\/\/ s - \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \t\/\/ t - \u043f\u0443\u043d\u043a\u0442 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f  \t\/\/ \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u044c \tlet queue = [] \t\/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c s \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \tqueue.push(s) \t\/\/ \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u043c s \u043a\u0430\u043a \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0432\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u043d\u0438\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \ts.visited = true \twhile(queue.length &gt; 0) { \t\t\/\/ \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 (\u0432\u0435\u0440\u0445\u043d\u0438\u0439) \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \t\tlet v = queue.shift() \t\t\/\/ abj[v] - \u0441\u043e\u0441\u0435\u0434\u0438 v \t\tfor(let neighbor of adj[v]) { \t\t\t\/\/ \u0435\u0441\u043b\u0438 \u0441\u043e\u0441\u0435\u0434 \u043d\u0435 \u043f\u043e\u0441\u0435\u0449\u0430\u043b\u0441\u044f \t\t\tif(!neighbor.visited) { \t\t\t\t\/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \t\t\t\tqueue.push(neighbor) \t\t\t\t\/\/ \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u043c \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u043a\u0430\u043a \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u043d\u0443\u044e \t\t\t\tneighbor.visited = true \t\t\t\t\/\/ \u0435\u0441\u043b\u0438 \u0441\u043e\u0441\u0435\u0434 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0443\u043d\u043a\u0442\u043e\u043c \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043c\u044b \u043f\u043e\u0431\u0435\u0434\u0438\u043b\u0438 \t\t\t\tif(neighbor === t) return true \t\t\t} \t\t}  \t} \t\/\/ \u0435\u0441\u043b\u0438 t \u043d\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043e, \u0437\u043d\u0430\u0447\u0438\u0442 \u043f\u0443\u043d\u043a\u0442\u0430 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \treturn false } <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0410\u043d\u0430\u043b\u0438\u0437 BFS<\/h4>\n<p>  \u041c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e BFS \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c\u0441\u044f \u043a \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u043c, \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u043e\u043d\u0438 \u0438\u043c\u0435\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u041e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u043f\u0435\u0440\u0435\u0434 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0435\u043c \u043f\u0443\u043d\u043a\u0442\u0430 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e, \u0432 \u0445\u0443\u0434\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, BFS \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u0441\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0438 \u0433\u0440\u0430\u043d\u0438.<\/p>\n<p>  \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e BFS \u043c\u043e\u0436\u0435\u0442 \u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043e\u043d \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0433\u0440\u0430\u0444\u0430\u043c\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e DFS \u0442\u0440\u0430\u0442\u0438\u0442 \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u043f\u0443\u0442\u044f\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0441\u0447\u0435\u0442\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043b\u043e\u0436\u043d\u044b\u043c\u0438. BFS \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0435\u0433\u043e \u043f\u0443\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438.<\/p>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f BFS \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 O(V + E), \u0430 \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0432\u043c\u0435\u0449\u0430\u044e\u0449\u0443\u044e \u0432\u0441\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b, \u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 O(V).<\/p>\n<h3>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0438\u0437 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0436\u0438\u0437\u043d\u0438<\/h3>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0438\u0437 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0436\u0438\u0437\u043d\u0438, \u0442\u043e \u0432\u043e\u0442 \u043a\u0430\u043a \u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0441\u0435\u0431\u0435 \u0440\u0430\u0431\u043e\u0442\u0443 DFS \u0438 BFS.<\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u044f \u0434\u0443\u043c\u0430\u044e \u043e DFS, \u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0441\u0435\u0431\u0435 \u043c\u044b\u0448\u044c \u0432 \u043b\u0430\u0431\u0438\u0440\u0438\u043d\u0442\u0435 \u0432 \u043f\u043e\u0438\u0441\u043a\u0430\u0445 \u0435\u0434\u044b. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u043a \u0446\u0435\u043b\u0438 \u043c\u044b\u0448\u044c \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d\u0430 \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437 \u0443\u043f\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0442\u0443\u043f\u0438\u043a, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0438 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043f\u0443\u0442\u0438, \u0438 \u0442\u0430\u043a \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043e\u043d\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u0442 \u0432\u044b\u0445\u043e\u0434 \u0438\u0437 \u043b\u0430\u0431\u0438\u0440\u0438\u043d\u0442\u0430 \u0438\u043b\u0438 \u0435\u0434\u0443.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/-e\/f3\/ji\/-ef3ji72zi8egr3xa26zqvt1x4u.jpeg\"><\/p>\n<p>  \u0423\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/kq\/hb\/dr\/kqhbdrkv6xstug0ss3l5bpr1l9k.png\"><\/p>\n<p>  \u0412 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043a\u043e\u0433\u0434\u0430 \u044f \u0434\u0443\u043c\u0430\u044e \u043e BFS, \u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0441\u0435\u0431\u0435 \u043a\u0440\u0443\u0433\u0438 \u043d\u0430 \u0432\u043e\u0434\u0435. \u041f\u0430\u0434\u0435\u043d\u0438\u0435 \u043a\u0430\u043c\u043d\u044f \u0432 \u0432\u043e\u0434\u0443 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044e \u0432\u043e\u0437\u043c\u0443\u0449\u0435\u043d\u0438\u044f (\u043a\u0440\u0443\u0433\u043e\u0432) \u0432\u043e \u0432\u0441\u0435\u0445 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u0445 \u043e\u0442 \u0446\u0435\u043d\u0442\u0440\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/pv\/lz\/zp\/pvlzzpnzfssjv8yzpkc49ovtsho.jpeg\"><\/p>\n<p>  \u0423\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/s-\/w9\/sc\/s-w9scwvyp93tvyk2zwimmfc_um.png\"><\/p>\n<h3>\u0412\u044b\u0432\u043e\u0434\u044b<\/h3>\n<p>  <\/p>\n<ul>\n<li>\u041f\u043e\u0438\u0441\u043a \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u0438 \u043f\u043e\u0438\u0441\u043a \u0432 \u0448\u0438\u0440\u0438\u043d\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u0445\u043e\u0434\u0430 \u0433\u0440\u0430\u0444\u0430.<\/li>\n<li>DFS \u0434\u0432\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0433\u0440\u0430\u043d\u044f\u043c \u0442\u0443\u0434\u0430 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e, \u0430 BFS \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0441\u043e\u0441\u0435\u0434\u044f\u043c \u0432 \u043f\u043e\u0438\u0441\u043a\u0430\u0445 \u0446\u0435\u043b\u0438.<\/li>\n<li>DFS \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0442\u0435\u043a, \u0430 BFS \u2014 \u043e\u0447\u0435\u0440\u0435\u0434\u044c.<\/li>\n<li>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u043e\u0438\u0445 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 O(V + E), \u0430 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u2014 O(V).<\/li>\n<li>\u0414\u0430\u043d\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0438\u043c\u0435\u044e\u0442 \u0440\u0430\u0437\u043d\u0443\u044e \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u0438\u044e, \u043d\u043e \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0432\u0430\u0436\u043d\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0433\u0440\u0430\u0444\u0430\u043c\u0438.<\/li>\n<\/ul>\n<p>  \u041f\u0440\u0438\u043c. \u043f\u0435\u0440.: \u044f \u043d\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442 \u043f\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0438 \u043e\u0448\u0438\u0431\u043e\u043a, \u043d\u0435\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0435\u0439 \u0438\u043b\u0438 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u0438 \u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u043e\u043a, \u043f\u0440\u043e\u0448\u0443 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043b\u0438\u0447\u043a\u0443 \u0434\u043b\u044f \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0443\u0442\u043e\u0447\u043d\u0435\u043d\u0438\u044f. \u0411\u0443\u0434\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u0435\u043b\u0435\u043d.<\/p>\n<p>  \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/504374\/\"> https:\/\/habr.com\/ru\/post\/504374\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/504374\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/_f\/kf\/kl\/_fkfkl3gfkmnwtes2eypbueifxe.png\"><\/p>\n<p>  \u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a.<\/p>\n<p>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/medium.com\/@trykv\/algorithms-on-graphs-lets-talk-depth-first-search-dfs-and-breadth-first-search-bfs-5250c31d831a\" rel=\"nofollow\">\u00abAlgorithms on Graphs: Let\u2019s talk Depth-First Search (DFS) and Breadth-First Search (BFS)\u00bb<\/a> \u0430\u0432\u0442\u043e\u0440\u0430 Try Khov.<\/p>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043e\u0431\u0445\u043e\u0434 \u0433\u0440\u0430\u0444\u0430?<\/h3>\n<p>  \u041f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043e\u0431\u0445\u043e\u0434 \u0433\u0440\u0430\u0444\u0430 \u2014 \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043e\u0442 \u043e\u0434\u043d\u043e\u0439 \u0435\u0433\u043e \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u043a \u0434\u0440\u0443\u0433\u043e\u0439 \u0432 \u043f\u043e\u0438\u0441\u043a\u0430\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0441\u0432\u044f\u0437\u0435\u0439 \u044d\u0442\u0438\u0445 \u0432\u0435\u0440\u0448\u0438\u043d. \u0421\u0432\u044f\u0437\u0438 (\u043b\u0438\u043d\u0438\u0438, \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u044e\u0449\u0438\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b) \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438, \u043f\u0443\u0442\u044f\u043c\u0438, \u0433\u0440\u0430\u043d\u044f\u043c\u0438 \u0438\u043b\u0438 \u0440\u0435\u0431\u0440\u0430\u043c\u0438 \u0433\u0440\u0430\u0444\u0430. \u0412\u0435\u0440\u0448\u0438\u043d\u044b \u0433\u0440\u0430\u0444\u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u043d\u0443\u044e\u0442\u0441\u044f \u0443\u0437\u043b\u0430\u043c\u0438.<\/p>\n<p>  \u0414\u0432\u0443\u043c\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c\u0438 \u043e\u0431\u0445\u043e\u0434\u0430 \u0433\u0440\u0430\u0444\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0438\u0441\u043a \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0443 (Depth-First Search, DFS) \u0438 \u043f\u043e\u0438\u0441\u043a \u0432 \u0448\u0438\u0440\u0438\u043d\u0443 (Breadth-First Search, BFS).<\/p>\n<p>  \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043e\u0431\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u0445\u043e\u0434\u0430 \u0433\u0440\u0430\u0444\u0430, \u043e\u043d\u0438 \u0438\u043c\u0435\u044e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u044f. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 DFS.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-304487","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/304487","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=304487"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/304487\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=304487"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=304487"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=304487"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}