{"id":336506,"date":"2022-08-03T09:00:21","date_gmt":"2022-08-03T09:00:21","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=336506"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=336506","title":{"rendered":"<span>\u0418\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0433\u0440\u0430\u0444 \u00ab\u043c\u0438\u0440 \u0442\u0435\u0441\u0435\u043d\u00bb \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Neo4j<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1ec\/5e6\/a29\/1ec5e6a296728d1e667878c22846d6fd.png\" width=\"1094\" height=\"730\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1ec\/5e6\/a29\/1ec5e6a296728d1e667878c22846d6fd.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u043e\u044f \u0441\u0435\u0441\u0442\u0440\u0430 \u043f\u0435\u0440\u0435\u0435\u0445\u0430\u043b\u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0433\u043e\u0440\u043e\u0434 \u0438 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0430\u0441\u044c \u0441 \u0441\u043e\u0441\u0435\u0434\u044f\u043c\u0438, \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0434\u0435\u0434\u0443\u0448\u043a\u0430 \u0438 \u0431\u0430\u0431\u0443\u0448\u043a\u0430 \u0435\u0435 \u0441\u043e\u0441\u0435\u0434\u0430 \u0438 \u043d\u0430\u0448\u0438 \u0431\u0430\u0431\u0443\u0448\u043a\u0430 \u0441 \u0434\u0435\u0434\u0443\u0448\u043a\u043e\u0439 \u0431\u044b\u043b\u0438 \u0445\u043e\u0440\u043e\u0448\u0438\u043c\u0438 \u0434\u0440\u0443\u0437\u044c\u044f\u043c\u0438 \u0438 \u043e\u0431\u0449\u0430\u043b\u0438\u0441\u044c, \u0436\u0438\u0432\u044f \u0440\u044f\u0434\u043e\u043c \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u0433\u043e\u0440\u043e\u0434\u0435 \u2013 \u0434\u0432\u0430 \u043f\u043e\u043a\u043e\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0437\u0430\u0434. \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u0435 \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0432\u044f\u0437\u0438. \u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0442\u0435\u043e\u0440\u0438\u0438 \u0441\u0435\u0442\u0435\u0439, \u043f\u0443\u0442\u0438, \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u044e\u0449\u0438\u0435 \u0443\u0437\u043b\u044b \u0441\u0435\u0442\u0438, \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043a\u043e\u0440\u043e\u0447\u0435, \u0447\u0435\u043c \u043c\u043e\u0433\u043b\u043e \u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0432 \u0441\u0435\u0442\u0438 \u0437\u043d\u0430\u0435\u0442 <em>k<\/em>\u00a0\u0434\u0440\u0443\u0433\u0438\u0445 \u043b\u044e\u0434\u0435\u0439, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e, \u043d\u0430\u0447\u0430\u0432 \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0432\u00a0<em>n<\/em>\u00a0\u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u043e\u0442 \u0443\u0437\u043b\u0430 \u043a \u0443\u0437\u043b\u0443, \u043c\u044b \u043d\u0430\u0439\u0434\u0435\u043c\u00a0<em>k\u207f<\/em>\u00a0\u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u043e\u0441\u0442, \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0443\u0442\u044c \u043e\u0442 \u043b\u044e\u0431\u043e\u0433\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0434\u043e \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0432 \u0433\u0440\u0430\u0444\u0435.<\/p>\n<p>\u041d\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0442\u044f\u0445 \u043c\u043d\u043e\u0433\u0438\u0435 \u043b\u044e\u0434\u0438, \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c\u0443 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0443, \u0442\u0430\u043a\u0436\u0435 \u0437\u043d\u0430\u044e\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430. \u0422\u0430\u043a\u043e\u0435 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0434\u0440\u0443\u0437\u044c\u044f\u043c\u0438 \u0434\u0440\u0443\u0437\u0435\u0439 \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u043e\u0432\u044b\u0445 \u043b\u044e\u0434\u0435\u0439, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u044f \u043c\u043e\u0433\u0443 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043d\u0430 \u043f\u0443\u0442\u0438 \u043e\u0442 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u0430.\u00a0 \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0439\u0442\u0438 \u0442\u0430\u043a\u0438\u0435 \u043f\u0443\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0432 \u0441\u043f\u043b\u043e\u0447\u0435\u043d\u043d\u043e\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435, \u0430 \u0434\u0430\u043b\u0435\u0435 \u0440\u0430\u0437\u0432\u0435\u0442\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u043e \u0441\u0430\u043c\u044b\u0445 \u043e\u0442\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u0443\u0433\u043e\u043b\u043a\u043e\u0432 \u0441\u0435\u0442\u0438.<\/p>\n<p>\u0412\u00a0<a href=\"https:\/\/www.cs.cornell.edu\/home\/kleinber\/networks-book\/networks-book-ch20.pdf\">\u0433\u043b\u0430\u0432\u0435 20 \u043a\u043d\u0438\u0433\u0438\u00a0<em>Networks Crowds and Markets<\/em><\/a> \u0435\u0435 \u0430\u0432\u0442\u043e\u0440\u044b \u0414\u044d\u0432\u0438\u0434 \u0418\u0437\u043b\u0438 \u0438 \u0414\u0436\u043e\u043d \u041a\u043b\u0435\u0439\u043d\u0431\u0435\u0440\u0433 \u0434\u0430\u044e\u0442 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043f\u043f\u0430\u0440\u0430\u0442, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439, \u043a\u0430\u043a \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043c\u0438\u0440\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0442\u044c \u0444\u0435\u043d\u043e\u043c\u0435\u043d\u044b, \u0443\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0432 \u0433\u0440\u0430\u0444 \u00ab\u043c\u0438\u0440 \u0442\u0435\u0441\u0435\u043d\u00bb. \u0412 \u044d\u0442\u043e\u0439 \u0442\u0435\u043e\u0440\u0438\u0438 \u0441\u043e\u0447\u0435\u0442\u0430\u0435\u0442\u0441\u044f \u0438\u0434\u0435\u044f\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Homophily\">\u0433\u043e\u043c\u043e\u0444\u0438\u043b\u0438\u0438<\/a>, \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u0445\u043e\u0436\u0438\u0435 \u043b\u044e\u0434\u0438 \u043a\u0443\u0447\u043a\u0443\u044e\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435, \u0438 \u0438\u0434\u0435\u044f \u0441\u043b\u0430\u0431\u044b\u0445 \u0441\u0432\u044f\u0437\u0435\u0439, \u0433\u0434\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0432\u0435\u0442\u0432\u044f\u0442\u0441\u044f \u0432 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0430\u0445 \u0432\u0441\u0435\u0439 \u0441\u0435\u0442\u0438. \u041e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043e \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0435 <a href=\"https:\/\/www.nature.com\/articles\/30918\">\u0414\u0443\u043d\u043a\u0430\u043d\u0430 \u0423\u043e\u0442\u0442\u0441\u0430 \u0438 \u0421\u0442\u0438\u0432\u0430 \u0421\u0442\u0440\u043e\u0433\u0430\u0446\u0430<\/a>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0441\u043b\u0435\u0434\u0438\u043c \u044d\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u0434\u0430, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Neo4j.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434, \u0432\u043e\u0439\u0434\u0438\u0442\u0435 \u0432\u00a0<a href=\"https:\/\/sandbox.neo4j.com\/\">\u043f\u0435\u0441\u043e\u0447\u043d\u0438\u0446\u0443<\/a>\u00a0\u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u201cNew Project.\u201d (\u041d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442). \u0414\u0430\u043b\u0435\u0435 \u0438\u0437 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0445 \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043e\u043a \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u00a0\u201cGraph Data Science\u201d.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/62d\/058\/a8c\/62d058a8c94f98c78c3808c389a46329.png\" width=\"1400\" height=\"464\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/62d\/058\/a8c\/62d058a8c94f98c78c3808c389a46329.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043f\u0435\u0441\u043e\u0447\u043d\u0438\u0446\u0443 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u0431\u044a\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u00ab\u0418\u0433\u0440\u0435 \u043f\u0440\u0435\u0441\u0442\u043e\u043b\u043e\u0432\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043d\u0430\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u044f. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0445 \u0443\u0434\u0430\u043b\u0438\u043c.<\/p>\n<pre><code class=\"sql\">MATCH (n)  DETACH DELETE n;<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043b\u043e\u0436\u0438\u043c \u0441\u0435\u0442\u043a\u0443 \u0438\u0437 \u0443\u0437\u043b\u043e\u0432 Person, 30 \u043d\u0430 30. \u041a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b Person \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0442\u0440\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430: \u0441\u0442\u0440\u043e\u043a\u0443, \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b.    <\/p>\n<pre><code class=\"sql\">UNWIND RANGE(1,30) AS row UNWIND RANGE(1,30) AS column CREATE (p:Person {row:row, column:column,       coordinates:toString(column) + ', ' + toString(row)});<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f\u00a0<code>KNOWS<\/code>\u00a0\u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0436\u0434\u044b\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u043b\u0438\u0446\u043e\u043c \u0438 \u043b\u0438\u0446\u043e\u043c, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c \u0432 \u0441\u0435\u0442\u043a\u0435 \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u043d\u0435\u0433\u043e. <\/p>\n<pre><code class=\"sql\">MATCH (p1:Person), (p2:Person) WHERE p1.row = p2.row      AND p1.column = p2.column - 1 CREATE (p1)-[:KNOWS]->(p2);<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f\u00a0<code>KNOWS<\/code>\u00a0\u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0436\u0434\u044b\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u043b\u0438\u0446\u043e\u043c \u0438 \u043b\u0438\u0446\u043e\u043c, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c \u0432 \u0441\u0435\u0442\u043a\u0435 \u0441\u0442\u0440\u043e\u0433\u043e \u043f\u043e\u0434 \u043d\u0438\u043c. <\/p>\n<pre><code class=\"sql\">MATCH (p1:Person), (p2:Person) WHERE p1.column = p2.column      AND p1.row = p2.row - 1 CREATE (p1)-[:KNOWS]->(p2);<\/code><\/pre>\n<p>\u041c\u0435\u0436\u0434\u0443 \u043a\u0430\u0436\u0434\u044b\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u043b\u0438\u0446\u043e\u043c \u0438 \u0434\u0432\u0443\u043c\u044f \u043b\u0438\u0446\u0430\u043c\u0438, \u0441\u043c\u0435\u0436\u043d\u044b\u043c\u0438 \u0441 \u043d\u0438\u043c \u043f\u043e \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438 \u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u043c\u0438\u0441\u044f \u043d\u0430 \u0440\u044f\u0434 \u043d\u0438\u0436\u0435. <\/p>\n<pre><code class=\"sql\">MATCH (p1:Person)-->(p2:Person) WHERE p1.row = p2.row-1 WITH (p1), (p2) MATCH (p2)--(p3) WHERE p3.row = p2.row CREATE (p1)-[:KNOWS]->(p3);<\/code><\/pre>\n<p>\u0423 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u0440\u0435\u0448\u0435\u0442\u0447\u0430\u0442\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d. \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c\u00a0<code>Person<\/code>\u00a0\u0438 \u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439, \u0430 \u0434\u0430\u043b\u0435\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u044d\u0442\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"sql\">MATCH (p:Person {row:5, column:5})--(n)  RETURN *;<\/code><\/pre>\n<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a4b\/4ba\/562\/a4b4ba562557c537dd5c4e192a849479.png\" alt=\"\u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043b\u0438\u0446\u0430 \u0441 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 5, 5\" title=\"\u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043b\u0438\u0446\u0430 \u0441 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 5, 5\" width=\"741\" height=\"708\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a4b\/4ba\/562\/a4b4ba562557c537dd5c4e192a849479.png\"\/><figcaption>\u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043b\u0438\u0446\u0430 \u0441 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 5, 5<\/figcaption><\/figure>\n<p>\u042f \u0432\u0438\u0436\u0443 \u043d\u0430 \u044d\u0442\u043e\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432. \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 \u0434\u043b\u044f data science \u043d\u0430 \u0433\u0440\u0430\u0444\u0430\u0445, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u043a\u0430\u043a\u043e\u0432\u0430 \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u043b\u044e\u0434\u0435\u0439 \u0432 \u043a\u0440\u0443\u0433\u0443 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0430\u043a\u0436\u0435 \u0437\u043d\u0430\u044e\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444.<\/p>\n<pre><code class=\"sql\">CALL gds.graph.create('base-grid', 'Person', {KNOWS:      {orientation:\"UNDIRECTED\"}});<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432.<\/p>\n<pre><code class=\"sql\">CALL gds.alpha.triangleCount.stream('base-grid')  YIELD  coefficient RETURN avg(coefficient) AS averageClusteringCoefficient<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1a1\/a6d\/6bf\/1a1a6d6bfb780d46412bfe9e2215e5a3.png\" alt=\"\u041a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432\" title=\"\u041a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432\" width=\"536\" height=\"170\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1a1\/a6d\/6bf\/1a1a6d6bfb780d46412bfe9e2215e5a3.png\"\/><figcaption>\u041a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432<\/figcaption><\/figure>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 0,44 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043b\u0438\u0448\u044c \u043e\u043a\u043e\u043b\u043e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u044b \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0445 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c. \u0422\u0430\u043a\u043e\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0442\u0438\u044f \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u0438\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u043f\u0443\u0442\u0438 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0442\u0435\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u0432 \u0441\u0435\u0442\u0438, \u0433\u0434\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0443\u0437\u043b\u043e\u0432 \u0438\u043c\u0435\u0435\u0442 \u0441\u0442\u0435\u043f\u0435\u043d\u044c 8.<\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u044d\u0442\u0443 \u0438\u0434\u0435\u044e. \u0412\u044b\u0437\u043e\u0432\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443\u00a0<code>allShortestPaths<\/code>, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0439 \u043f\u0443\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0436\u0434\u044b\u043c\u0438 \u0434\u0432\u0443\u043c\u044f \u0443\u0437\u043b\u0430\u043c\u0438 \u0432 \u0433\u0440\u0430\u0444\u0435. \u0414\u0430\u043b\u0435\u0435 \u043e\u0431\u043e\u0431\u0449\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b.<\/p>\n<pre><code class=\"sql\">CALL gds.alpha.allShortestPaths.stream('small-world') YIELD sourceNodeId, targetNodeId, distance RETURN max(distance) AS maxDistance,       min(distance) AS minDistance,       avg(distance) AS avgDistance,       count(distance) AS pathCount;<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/66f\/ac0\/f5d\/66fac0f5d20c5910d0c9fe031ef22673.png\" alt=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 allShortestPaths\" title=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 allShortestPaths\" width=\"1094\" height=\"138\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/66f\/ac0\/f5d\/66fac0f5d20c5910d0c9fe031ef22673.png\"\/><figcaption>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 allShortestPaths<\/figcaption><\/figure>\n<p>\u042f \u0431\u044b\u043b \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d, \u0447\u0442\u043e \u043c\u043e\u0439 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440-\u043f\u0435\u0441\u043e\u0447\u043d\u0438\u0446\u0430 \u0441\u043c\u043e\u0433 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c 809\u00a0100 \u043f\u0443\u0442\u0435\u0439 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0437\u0430 \u0441\u0435\u043a\u0443\u043d\u0434\u0443. \u0414\u0438\u0430\u043c\u0435\u0442\u0440 \u0433\u0440\u0430\u0444\u0430 \u2013 \u044d\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u0434\u043b\u0438\u043d\u043d\u044b\u0439 \u0438\u0437 \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0445 \u043f\u0443\u0442\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438. \u0414\u0438\u0430\u043c\u0435\u0442\u0440 \u0432 29 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u0432 \u044d\u0442\u043e\u043c \u0433\u0440\u0430\u0444\u0435 \u0432\u043f\u043e\u043b\u043d\u0435 \u043b\u043e\u0433\u0438\u0447\u0435\u043d. \u041d\u0438\u043a\u0430\u043a\u0438\u0435 \u0434\u0432\u0430 \u0443\u0437\u043b\u0430 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435 \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430, \u0447\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043d\u0430 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u044b\u0445 \u043a\u0440\u0430\u044f\u0445 \u0441\u0435\u0442\u043a\u0438.<\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043d \u043f\u0443\u0442\u0435\u0439.<\/p>\n<pre><code class=\"sql\">CALL gds.alpha.allShortestPaths.stream('base-grid') YIELD sourceNodeId, targetNodeId, distance RETURN distance, count(*) AS pathCount ORDER BY distance;<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0441\u0445\u0435\u043c\u0430 \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/29d\/b55\/acc\/29db55acc5aefcb1b58a5c6b7442d3ee.png\" alt=\"\u0413\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u0438\u043d \u043f\u0443\u0442\u0435\u0439\" title=\"\u0413\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u0438\u043d \u043f\u0443\u0442\u0435\u0439\" width=\"751\" height=\"450\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/29d\/b55\/acc\/29db55acc5aefcb1b58a5c6b7442d3ee.png\"\/><figcaption>\u0413\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u0438\u043d \u043f\u0443\u0442\u0435\u0439<\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0433\u0440\u0430\u0444, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 \u043d\u0435\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 \u0442\u0430\u043a\u0438\u043c\u0438 \u0443\u0437\u043b\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u043c\u0435\u0436\u043d\u044b\u043c\u0438 \u0432 \u0441\u0435\u0442\u043a\u0435. \u041c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u044d\u0442\u0438 \u0441\u043b\u0430\u0431\u044b\u0435 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f\u043c\u0438: \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043b\u044e\u0434\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435, \u043d\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0442 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043a\u0440\u0443\u0433\u0430 \u0432\u0430\u0448\u0438\u0445 \u0434\u0440\u0443\u0437\u0435\u0439. <\/p>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043e\u0439 <code>apoc.periodic.iterate<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0443\u0437\u043b\u044b \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0443\u0437\u043b\u0443 \u0434\u0432\u0435 \u043d\u0435\u0441\u043c\u0435\u0436\u043d\u044b\u0445 \u0441\u0432\u044f\u0437\u0438.<\/p>\n<pre><code class=\"sql\">CALL apoc.periodic.iterate(      'MATCH (p1) RETURN p1',      'MATCH (p2)       WHERE p1 &lt;> p2 AND NOT EXISTS((p1)--(p2))       WITH p1, p2, rand() AS rand           ORDER BY rand LIMIT 2       MERGE (p1)-[:KNOWS {adjacent:False}]->(p2)',      {batchSize:1} )<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043d\u043e\u0432\u044c \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 Person \u0441 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438\u00a0 5, 5. \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u044d\u0442\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u0434\u0435\u0441\u044f\u0442\u044c \u0441\u0432\u044f\u0437\u0435\u0439. \u0412\u043e\u0441\u0435\u043c\u044c \u0438\u0437 \u043d\u0438\u0445 \u0432 \u0441\u0435\u0442\u043a\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u043c\u0435\u0436\u043d\u044b\u043c\u0438, \u0430 \u0434\u0432\u0435 \u043d\u043e\u0432\u044b\u0445 \u0441\u0432\u044f\u0437\u0438 \u2013 \u043d\u0435\u0441\u043c\u0435\u0436\u043d\u044b\u0435.<\/p>\n<pre><code class=\"sql\">MATCH (p:Person {row:5, column:5})--(n)  RETURN *;<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fc7\/c1f\/7d1\/fc7c1f7d12b8f91e05ba4dc3c3edcc32.png\" alt=\"\u0421\u043e\u0441\u0435\u0434\u0438 \u0443\u0437\u043b\u0430, \u0438\u043c\u0435\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b 5, 5\" title=\"\u0421\u043e\u0441\u0435\u0434\u0438 \u0443\u0437\u043b\u0430, \u0438\u043c\u0435\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b 5, 5\" width=\"920\" height=\"854\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fc7\/c1f\/7d1\/fc7c1f7d12b8f91e05ba4dc3c3edcc32.png\"\/><figcaption>\u0421\u043e\u0441\u0435\u0434\u0438 \u0443\u0437\u043b\u0430, \u0438\u043c\u0435\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b 5, 5<\/figcaption><\/figure>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u043e\u0432\u044b\u0439 \u0433\u0440\u0430\u0444, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Graph Data Science Library.<\/p>\n<pre><code class=\"sql\">CALL gds.graph.create('small-world', 'Person',       {KNOWS:{orientation:\"UNDIRECTED\"}});<\/code><\/pre>\n<p>\u041a\u0430\u043a\u043e\u0432 \u0441\u0440\u0435\u0434\u043d\u0438\u0439 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0430? <\/p>\n<pre><code class=\"sql\">CALL gds.alpha.triangleCount.stream('base-grid')  YIELD  coefficient RETURN avg(coefficient) AS averageClusteringCoefficient<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/04f\/98c\/1d8\/04f98c1d821e95cb406f964f7368b01e.png\" alt=\"\u041a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438\" title=\"\u041a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438\" width=\"569\" height=\"175\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/04f\/98c\/1d8\/04f98c1d821e95cb406f964f7368b01e.png\"\/><figcaption>\u041a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438<\/figcaption><\/figure>\n<p>\u0412 \u043d\u043e\u0432\u043e\u043c \u0433\u0440\u0430\u0444\u0435 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043d\u0430\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f 18% \u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u043d\u0430\u044e\u0442 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0437\u043d\u0430\u044e\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430. \u041f\u0440\u0438 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u0434\u0432\u0443\u0445 \u043d\u043e\u0432\u044b\u0445 \u0434\u0440\u0443\u0437\u0435\u0439 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0438 \u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435\u043c \u043c\u0435\u0436\u0434\u0443 \u0434\u0440\u0443\u0437\u044c\u044f\u043c\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u043f\u0443\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043f\u0440\u043e\u0433\u043e\u043d\u0438\u043c\u00a0<code>allShortestPaths<\/code>\u00a0\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443.<\/p>\n<pre><code class=\"sql\">CALL gds.alpha.allShortestPaths.stream('small-world') YIELD sourceNodeId, targetNodeId, distance RETURN max(distance) AS maxDistance,       min(distance) AS minDistance,       avg(distance) AS avgDistance,       count(distance) AS pathCount;<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4ef\/70b\/c69\/4ef70bc69660cfcb663cb9eaa374bfe0.png\" alt=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 allShortestPaths \" title=\"\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 allShortestPaths \" width=\"1094\" height=\"117\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4ef\/70b\/c69\/4ef70bc69660cfcb663cb9eaa374bfe0.png\"\/><figcaption>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 allShortestPaths <\/figcaption><\/figure>\n<p>\u0414\u0438\u0430\u043c\u0435\u0442\u0440 \u0433\u0440\u0430\u0444\u0430 \u0440\u0435\u0437\u043a\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u0441\u044f \u0441 29 \u0434\u043e 5, \u0430 \u0441\u0440\u0435\u0434\u043d\u044f\u044f \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u044f \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b\u0430\u0441\u044c \u0432\u0441\u0435\u0433\u043e \u0434\u043e 3. \u0418 \u0432\u043f\u0440\u0430\u0432\u0434\u0443 \u043c\u0438\u0440 \u0442\u0435\u0441\u0435\u043d! <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u043e\u0432\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043d \u043f\u0443\u0442\u0435\u0439.<\/p>\n<pre><code class=\"sql\">CALL gds.alpha.allShortestPaths.stream('small-world') YIELD sourceNodeId, targetNodeId, distance RETURN distance, count(*) AS pathCount ORDER BY distance;<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/809\/018\/72d\/80901872d3e6b7e8f1a18623525cbeae.png\" alt=\"\" title=\"\" width=\"751\" height=\"450\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/809\/018\/72d\/80901872d3e6b7e8f1a18623525cbeae.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041e\u0447\u0435\u043d\u044c \u043c\u0430\u043b \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u0442\u0430\u043a\u0438\u0445 \u043b\u044e\u0434\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0441\u0442\u043e\u044f\u0442 \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430 \u043d\u0430 \u043f\u044f\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432. \u041e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0445 \u043f\u0443\u0442\u0435\u0439 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442 \u043f\u043e \u0442\u0440\u0438-\u0447\u0435\u0442\u044b\u0440\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430.<\/p>\n<p>\u041c\u044b \u043d\u0430\u0447\u0430\u043b\u0438 \u0441 \u0441\u0435\u0442\u0438, \u0433\u0434\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0437\u043d\u0430\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u044f\u043c\u044b\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439. \u0414\u043e\u0431\u0430\u0432\u0438\u0432 \u043f\u043e \u0434\u0432\u0435 \u043d\u0435\u0441\u043c\u0435\u0436\u043d\u044b\u0445 \u0441\u0432\u044f\u0437\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0437\u043b\u0430, \u043c\u044b \u0440\u0435\u0437\u043a\u043e \u0441\u043d\u0438\u0437\u0438\u043b\u0438 \u0434\u0438\u0430\u043c\u0435\u0442\u0440 \u0433\u0440\u0430\u0444\u0430 \u0438 \u0441\u0440\u0435\u0434\u043d\u044e\u044e \u0434\u043b\u0438\u043d\u0443 \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0435\u0433\u043e \u043f\u0443\u0442\u0438. \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043d\u043e\u0432\u043e \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0442\u044c \u043a\u043e\u0434 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0438\u043b\u0438 \u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043d\u0435\u0441\u043c\u0435\u0436\u043d\u044b\u0445 \u0441\u0432\u044f\u0437\u0435\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u0418\u0437\u043b\u0438 \u0438 \u041a\u043b\u0435\u0439\u043d\u0431\u0435\u0440\u0433 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442, \u0447\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u044c \u00ab\u043c\u0438\u0440 \u0442\u0435\u0441\u0435\u043d\u00bb \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u0430\u0436\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043c\u0435\u0436\u043d\u044b\u0435 \u0441\u0432\u044f\u0437\u0438. \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043d\u0435\u0441\u043c\u0435\u0436\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u0438 \u0434\u043b\u044f \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0443\u0437\u043b\u043e\u0432 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0443\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0434\u043b\u0438\u043d\u0443 \u043f\u0443\u0442\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438.<\/p>\n<p>\u00a0<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \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\/company\/piter\/blog\/680576\/\"> https:\/\/habr.com\/ru\/company\/piter\/blog\/680576\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u043e\u044f \u0441\u0435\u0441\u0442\u0440\u0430 \u043f\u0435\u0440\u0435\u0435\u0445\u0430\u043b\u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0433\u043e\u0440\u043e\u0434 \u0438 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0430\u0441\u044c \u0441 \u0441\u043e\u0441\u0435\u0434\u044f\u043c\u0438, \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0434\u0435\u0434\u0443\u0448\u043a\u0430 \u0438 \u0431\u0430\u0431\u0443\u0448\u043a\u0430 \u0435\u0435 \u0441\u043e\u0441\u0435\u0434\u0430 \u0438 \u043d\u0430\u0448\u0438 \u0431\u0430\u0431\u0443\u0448\u043a\u0430 \u0441 \u0434\u0435\u0434\u0443\u0448\u043a\u043e\u0439 \u0431\u044b\u043b\u0438 \u0445\u043e\u0440\u043e\u0448\u0438\u043c\u0438 \u0434\u0440\u0443\u0437\u044c\u044f\u043c\u0438 \u0438 \u043e\u0431\u0449\u0430\u043b\u0438\u0441\u044c, \u0436\u0438\u0432\u044f \u0440\u044f\u0434\u043e\u043c \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u0433\u043e\u0440\u043e\u0434\u0435 \u2013 \u0434\u0432\u0430 \u043f\u043e\u043a\u043e\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0437\u0430\u0434. \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u0435 \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0432\u044f\u0437\u0438. \u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0442\u0435\u043e\u0440\u0438\u0438 \u0441\u0435\u0442\u0435\u0439, \u043f\u0443\u0442\u0438, \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u044e\u0449\u0438\u0435 \u0443\u0437\u043b\u044b \u0441\u0435\u0442\u0438, \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043a\u043e\u0440\u043e\u0447\u0435, \u0447\u0435\u043c \u043c\u043e\u0433\u043b\u043e \u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0432 \u0441\u0435\u0442\u0438 \u0437\u043d\u0430\u0435\u0442 <em>k<\/em>\u00a0\u0434\u0440\u0443\u0433\u0438\u0445 \u043b\u044e\u0434\u0435\u0439, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e, \u043d\u0430\u0447\u0430\u0432 \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0432\u00a0<em>n<\/em>\u00a0\u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u043e\u0442 \u0443\u0437\u043b\u0430 \u043a \u0443\u0437\u043b\u0443, \u043c\u044b \u043d\u0430\u0439\u0434\u0435\u043c\u00a0<em>k\u207f<\/em>\u00a0\u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u043e\u0441\u0442, \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0443\u0442\u044c \u043e\u0442 \u043b\u044e\u0431\u043e\u0433\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0434\u043e \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0432 \u0433\u0440\u0430\u0444\u0435.<\/p>\n<p>\u041d\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0442\u044f\u0445 \u043c\u043d\u043e\u0433\u0438\u0435 \u043b\u044e\u0434\u0438, \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c\u0443 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0443, \u0442\u0430\u043a\u0436\u0435 \u0437\u043d\u0430\u044e\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430. \u0422\u0430\u043a\u043e\u0435 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0434\u0440\u0443\u0437\u044c\u044f\u043c\u0438 \u0434\u0440\u0443\u0437\u0435\u0439 \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u043e\u0432\u044b\u0445 \u043b\u044e\u0434\u0435\u0439, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u044f \u043c\u043e\u0433\u0443 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043d\u0430 \u043f\u0443\u0442\u0438 \u043e\u0442 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u0430.\u00a0 \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0439\u0442\u0438 \u0442\u0430\u043a\u0438\u0435 \u043f\u0443\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0432 \u0441\u043f\u043b\u043e\u0447\u0435\u043d\u043d\u043e\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435, \u0430 \u0434\u0430\u043b\u0435\u0435 \u0440\u0430\u0437\u0432\u0435\u0442\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u043e \u0441\u0430\u043c\u044b\u0445 \u043e\u0442\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u0443\u0433\u043e\u043b\u043a\u043e\u0432 \u0441\u0435\u0442\u0438.<\/p>\n<p>\u0412\u00a0<a href=\"https:\/\/www.cs.cornell.edu\/home\/kleinber\/networks-book\/networks-book-ch20.pdf\">\u0433\u043b\u0430\u0432\u0435 20 \u043a\u043d\u0438\u0433\u0438\u00a0<em>Networks Crowds and Markets<\/em><\/a> \u0435\u0435 \u0430\u0432\u0442\u043e\u0440\u044b \u0414\u044d\u0432\u0438\u0434 \u0418\u0437\u043b\u0438 \u0438 \u0414\u0436\u043e\u043d \u041a\u043b\u0435\u0439\u043d\u0431\u0435\u0440\u0433 \u0434\u0430\u044e\u0442 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043f\u043f\u0430\u0440\u0430\u0442, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439, \u043a\u0430\u043a \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043c\u0438\u0440\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0442\u044c \u0444\u0435\u043d\u043e\u043c\u0435\u043d\u044b, \u0443\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0432 \u0433\u0440\u0430\u0444 \u00ab\u043c\u0438\u0440 \u0442\u0435\u0441\u0435\u043d\u00bb. \u0412 \u044d\u0442\u043e\u0439 \u0442\u0435\u043e\u0440\u0438\u0438 \u0441\u043e\u0447\u0435\u0442\u0430\u0435\u0442\u0441\u044f \u0438\u0434\u0435\u044f\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Homophily\">\u0433\u043e\u043c\u043e\u0444\u0438\u043b\u0438\u0438<\/a>, \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u0445\u043e\u0436\u0438\u0435 \u043b\u044e\u0434\u0438 \u043a\u0443\u0447\u043a\u0443\u044e\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435, \u0438 \u0438\u0434\u0435\u044f \u0441\u043b\u0430\u0431\u044b\u0445 \u0441\u0432\u044f\u0437\u0435\u0439, \u0433\u0434\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0432\u0435\u0442\u0432\u044f\u0442\u0441\u044f \u0432 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0430\u0445 \u0432\u0441\u0435\u0439 \u0441\u0435\u0442\u0438. \u041e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043e \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0435 <a href=\"https:\/\/www.nature.com\/articles\/30918\">\u0414\u0443\u043d\u043a\u0430\u043d\u0430 \u0423\u043e\u0442\u0442\u0441\u0430 \u0438 \u0421\u0442\u0438\u0432\u0430 \u0421\u0442\u0440\u043e\u0433\u0430\u0446\u0430<\/a>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0441\u043b\u0435\u0434\u0438\u043c \u044d\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u0434\u0430, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Neo4j.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434, \u0432\u043e\u0439\u0434\u0438\u0442\u0435 \u0432\u00a0<a href=\"https:\/\/sandbox.neo4j.com\/\">\u043f\u0435\u0441\u043e\u0447\u043d\u0438\u0446\u0443<\/a>\u00a0\u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u201cNew Project.\u201d (\u041d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442). \u0414\u0430\u043b\u0435\u0435 \u0438\u0437 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0445 \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043e\u043a \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u00a0\u201cGraph Data Science\u201d.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043f\u0435\u0441\u043e\u0447\u043d\u0438\u0446\u0443 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u0431\u044a\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u00ab\u0418\u0433\u0440\u0435 \u043f\u0440\u0435\u0441\u0442\u043e\u043b\u043e\u0432\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043d\u0430\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u044f. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0445 \u0443\u0434\u0430\u043b\u0438\u043c.<\/p>\n<pre><code class=\"sql\">MATCH (n)  DETACH DELETE n;<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043b\u043e\u0436\u0438\u043c \u0441\u0435\u0442\u043a\u0443 \u0438\u0437 \u0443\u0437\u043b\u043e\u0432 Person, 30 \u043d\u0430 30. \u041a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b Person \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0442\u0440\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430: \u0441\u0442\u0440\u043e\u043a\u0443, \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b.    <\/p>\n<pre><code class=\"sql\">UNWIND RANGE(1,30) AS row UNWIND RANGE(1,30) AS column CREATE (p:Person {row:row, column:column,       coordinates:toString(column) + ', ' + toString(row)});<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f\u00a0<code>KNOWS<\/code>\u00a0\u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0436\u0434\u044b\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u043b\u0438\u0446\u043e\u043c \u0438 \u043b\u0438\u0446\u043e\u043c, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c \u0432 \u0441\u0435\u0442\u043a\u0435 \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u043d\u0435\u0433\u043e. <\/p>\n<pre><code class=\"sql\">MATCH (p1:Person), (p2:Person) WHERE p1.row = p2.row      AND p1.column = p2.column - 1 CREATE (p1)-[:KNOWS]->(p2);<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f\u00a0<code>KNOWS<\/code>\u00a0\u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0436\u0434\u044b\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u043b\u0438\u0446\u043e\u043c \u0438 \u043b\u0438\u0446\u043e\u043c, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c \u0432 \u0441\u0435\u0442\u043a\u0435 \u0441\u0442\u0440\u043e\u0433\u043e \u043f\u043e\u0434 \u043d\u0438\u043c. <\/p>\n<pre><code class=\"sql\">MATCH (p1:Person), (p2:Person) WHERE p1.column = p2.column      AND p1.row = p2.row - 1 CREATE (p1)-[:KNOWS]->(p2);<\/code><\/pre>\n<p>\u041c\u0435\u0436\u0434\u0443 \u043a\u0430\u0436\u0434\u044b\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u043b\u0438\u0446\u043e\u043c \u0438 \u0434\u0432\u0443\u043c\u044f \u043b\u0438\u0446\u0430\u043c\u0438, \u0441\u043c\u0435\u0436\u043d\u044b\u043c\u0438 \u0441 \u043d\u0438\u043c \u043f\u043e \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438 \u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u043c\u0438\u0441\u044f \u043d\u0430 \u0440\u044f\u0434 \u043d\u0438\u0436\u0435. <\/p>\n<pre><code class=\"sql\">MATCH (p1:Person)-->(p2:Person) WHERE p1.row = p2.row-1 WITH (p1), (p2) MATCH (p2)--(p3) WHERE p3.row = p2.row CREATE (p1)-[:KNOWS]->(p3);<\/code><\/pre>\n<p>\u0423 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u0440\u0435\u0448\u0435\u0442\u0447\u0430\u0442\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d. \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c\u00a0<code>Person<\/code>\u00a0\u0438 \u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439, \u0430 \u0434\u0430\u043b\u0435\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u044d\u0442\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"sql\">MATCH (p:Person {row:5, column:5})--(n)  RETURN *;<\/code><\/pre>\n<\/p>\n<figure class=\"full-width\"><figcaption>\u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043b\u0438\u0446\u0430 \u0441 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 5, 5<\/figcaption><\/figure>\n<p>\u042f \u0432\u0438\u0436\u0443 \u043d\u0430 \u044d\u0442\u043e\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432. \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 \u0434\u043b\u044f data science \u043d\u0430 \u0433\u0440\u0430\u0444\u0430\u0445, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u043a\u0430\u043a\u043e\u0432\u0430 \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u043b\u044e\u0434\u0435\u0439 \u0432 \u043a\u0440\u0443\u0433\u0443 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0430\u043a\u0436\u0435 \u0437\u043d\u0430\u044e\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444.<\/p>\n<pre><code class=\"sql\">CALL gds.graph.create('base-grid', 'Person', {KNOWS:      {orientation:\"UNDIRECTED\"}});<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432.<\/p>\n<pre><code class=\"sql\">CALL gds.alpha.triangleCount.stream('base-grid')  YIELD  coefficient RETURN avg(coefficient) AS averageClusteringCoefficient<\/code><\/pre>\n<figure class=\"full-width\"><figcaption>\u041a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432<\/figcaption><\/figure>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 0,44 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043b\u0438\u0448\u044c \u043e\u043a\u043e\u043b\u043e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u044b \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0445 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c. \u0422\u0430\u043a\u043e\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0442\u0438\u044f \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u0438\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u043f\u0443\u0442\u0438 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0442\u0435\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u0432 \u0441\u0435\u0442\u0438, \u0433\u0434\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0443\u0437\u043b\u043e\u0432 \u0438\u043c\u0435\u0435\u0442 \u0441\u0442\u0435\u043f\u0435\u043d\u044c 8.<\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u044d\u0442\u0443 \u0438\u0434\u0435\u044e. \u0412\u044b\u0437\u043e\u0432\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443\u00a0<code>allShortestPaths<\/code>, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0439 \u043f\u0443\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0436\u0434\u044b\u043c\u0438 \u0434\u0432\u0443\u043c\u044f \u0443\u0437\u043b\u0430\u043c\u0438 \u0432 \u0433\u0440\u0430\u0444\u0435. \u0414\u0430\u043b\u0435\u0435 \u043e\u0431\u043e\u0431\u0449\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b.<\/p>\n<pre><code class=\"sql\">CALL gds.alpha.allShortestPaths.stream('small-world') YIELD sourceNodeId, targetNodeId, distance RETURN max(distance) AS maxDistance,       min(distance) AS minDistance,       avg(distance) AS avgDistance,       count(distance) AS pathCount;<\/code><\/pre>\n<figure class=\"full-width\"><figcaption>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 allShortestPaths<\/figcaption><\/figure>\n<p>\u042f \u0431\u044b\u043b \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d, \u0447\u0442\u043e \u043c\u043e\u0439 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440-\u043f\u0435\u0441\u043e\u0447\u043d\u0438\u0446\u0430 \u0441\u043c\u043e\u0433 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c 809\u00a0100 \u043f\u0443\u0442\u0435\u0439 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0437\u0430 \u0441\u0435\u043a\u0443\u043d\u0434\u0443. \u0414\u0438\u0430\u043c\u0435\u0442\u0440 \u0433\u0440\u0430\u0444\u0430 \u2013 \u044d\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u0434\u043b\u0438\u043d\u043d\u044b\u0439 \u0438\u0437 \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0445 \u043f\u0443\u0442\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438. \u0414\u0438\u0430\u043c\u0435\u0442\u0440 \u0432 29 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432 \u0432 \u044d\u0442\u043e\u043c \u0433\u0440\u0430\u0444\u0435 \u0432\u043f\u043e\u043b\u043d\u0435 \u043b\u043e\u0433\u0438\u0447\u0435\u043d. \u041d\u0438\u043a\u0430\u043a\u0438\u0435 \u0434\u0432\u0430 \u0443\u0437\u043b\u0430 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435 \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430, \u0447\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043d\u0430 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u044b\u0445 \u043a\u0440\u0430\u044f\u0445 \u0441\u0435\u0442\u043a\u0438.<\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043d \u043f\u0443\u0442\u0435\u0439.<\/p>\n<pre><code class=\"sql\">CALL gds.alpha.allShortestPaths.stream('base-grid') YIELD sourceNodeId, targetNodeId, distance RETURN distance, count(*) AS pathCount ORDER BY distance;<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0441\u0445\u0435\u043c\u0430 \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438.<\/p>\n<figure class=\"full-width\"><figcaption>\u0413\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u0438\u043d \u043f\u0443\u0442\u0435\u0439<\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0433\u0440\u0430\u0444, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 \u043d\u0435\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 \u0442\u0430\u043a\u0438\u043c\u0438 \u0443\u0437\u043b\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u043c\u0435\u0436\u043d\u044b\u043c\u0438 \u0432 \u0441\u0435\u0442\u043a\u0435. \u041c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u044d\u0442\u0438 \u0441\u043b\u0430\u0431\u044b\u0435 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f\u043c\u0438: \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043b\u044e\u0434\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435, \u043d\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0442 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043a\u0440\u0443\u0433\u0430 \u0432\u0430\u0448\u0438\u0445 \u0434\u0440\u0443\u0437\u0435\u0439. <\/p>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043e\u0439 <code>apoc.periodic.iterate<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0443\u0437\u043b\u044b \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0443\u0437\u043b\u0443 \u0434\u0432\u0435 \u043d\u0435\u0441\u043c\u0435\u0436\u043d\u044b\u0445 \u0441\u0432\u044f\u0437\u0438.<\/p>\n<pre><code class=\"sql\">CALL apoc.periodic.iterate(      'MATCH (p1) RETURN p1',      'MATCH (p2)       WHERE p1 &lt;> p2 AND NOT EXISTS((p1)--(p2))       WITH p1, p2, rand() AS rand           ORDER BY rand LIMIT 2       MERGE (p1)-[:KNOWS {adjacent:False}]->(p2)',      {batchSize:1} )<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043d\u043e\u0432\u044c \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 Person \u0441 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438\u00a0 5, 5. \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u044d\u0442\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u0434\u0435\u0441\u044f\u0442\u044c \u0441\u0432\u044f\u0437\u0435\u0439. \u0412\u043e\u0441\u0435\u043c\u044c \u0438\u0437 \u043d\u0438\u0445 \u0432 \u0441\u0435\u0442\u043a\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u043c\u0435\u0436\u043d\u044b\u043c\u0438, \u0430 \u0434\u0432\u0435 \u043d\u043e\u0432\u044b\u0445 \u0441\u0432\u044f\u0437\u0438 \u2013 \u043d\u0435\u0441\u043c\u0435\u0436\u043d\u044b\u0435.<\/p>\n<pre><code class=\"sql\">MATCH (p:Person {row:5, column:5})--(n)  RETURN *;<\/code><\/pre>\n<figure class=\"full-width\"><figcaption>\u0421\u043e\u0441\u0435\u0434\u0438 \u0443\u0437\u043b\u0430, \u0438\u043c\u0435\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b 5, 5<\/figcaption><\/figure>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u043e\u0432\u044b\u0439 \u0433\u0440\u0430\u0444, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Graph Data Science Library.<\/p>\n<pre><code class=\"sql\">CALL gds.graph.create('small-world', 'Person',       {KNOWS:{orientation:\"UNDIRECTED\"}});<\/code><\/pre>\n<p>\u041a\u0430\u043a\u043e\u0432 \u0441\u0440\u0435\u0434\u043d\u0438\u0439 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0430? <\/p>\n<pre><code class=\"sql\">CALL gds.alpha.triangleCount.stream('base-grid')  YIELD  coefficient RETURN avg(coefficient) AS averageClusteringCoefficient<\/code><\/pre>\n<figure class=\"full-width\"><figcaption>\u041a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438<\/figcaption><\/figure>\n<p>\u0412 \u043d\u043e\u0432\u043e\u043c \u0433\u0440\u0430\u0444\u0435 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043d\u0430\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f 18% \u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u043d\u0430\u044e\u0442 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0437\u043d\u0430\u044e\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430. \u041f\u0440\u0438 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u0434\u0432\u0443\u0445 \u043d\u043e\u0432\u044b\u0445 \u0434\u0440\u0443\u0437\u0435\u0439 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0438 \u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435\u043c \u043c\u0435\u0436\u0434\u0443 \u0434\u0440\u0443\u0437\u044c\u044f\u043c\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u043f\u0443\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043f\u0440\u043e\u0433\u043e\u043d\u0438\u043c\u00a0<code>allShortestPaths<\/code>\u00a0\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443.<\/p>\n<pre><code class=\"sql\">CALL gds.alpha.allShortestPaths.stream('small-world') YIELD sourceNodeId, targetNodeId, distance RETURN max(distance) AS maxDistance,       min(distance) AS minDistance,       avg(distance) AS avgDistance,       count(distance) AS pathCount;<\/code><\/pre>\n<figure class=\"full-width\"><figcaption>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 allShortestPaths <\/figcaption><\/figure>\n<p>\u0414\u0438\u0430\u043c\u0435\u0442\u0440 \u0433\u0440\u0430\u0444\u0430 \u0440\u0435\u0437\u043a\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u0441\u044f \u0441 29 \u0434\u043e 5, \u0430 \u0441\u0440\u0435\u0434\u043d\u044f\u044f \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u044f \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b\u0430\u0441\u044c \u0432\u0441\u0435\u0433\u043e \u0434\u043e 3. \u0418 \u0432\u043f\u0440\u0430\u0432\u0434\u0443 \u043c\u0438\u0440 \u0442\u0435\u0441\u0435\u043d! <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u043e\u0432\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043d \u043f\u0443\u0442\u0435\u0439.<\/p>\n<pre><code class=\"sql\">CALL gds.alpha.allShortestPaths.stream('small-world') YIELD sourceNodeId, targetNodeId, distance RETURN distance, count(*) AS pathCount ORDER BY distance;<\/code><\/pre>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041e\u0447\u0435\u043d\u044c \u043c\u0430\u043b \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u0442\u0430\u043a\u0438\u0445 \u043b\u044e\u0434\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0441\u0442\u043e\u044f\u0442 \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430 \u043d\u0430 \u043f\u044f\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432. \u041e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0445 \u043f\u0443\u0442\u0435\u0439 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442 \u043f\u043e \u0442\u0440\u0438-\u0447\u0435\u0442\u044b\u0440\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430.<\/p>\n<p>\u041c\u044b \u043d\u0430\u0447\u0430\u043b\u0438 \u0441 \u0441\u0435\u0442\u0438, \u0433\u0434\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0437\u043d\u0430\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u044f\u043c\u044b\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439. \u0414\u043e\u0431\u0430\u0432\u0438\u0432 \u043f\u043e \u0434\u0432\u0435 \u043d\u0435\u0441\u043c\u0435\u0436\u043d\u044b\u0445 \u0441\u0432\u044f\u0437\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0437\u043b\u0430, \u043c\u044b \u0440\u0435\u0437\u043a\u043e \u0441\u043d\u0438\u0437\u0438\u043b\u0438 \u0434\u0438\u0430\u043c\u0435\u0442\u0440 \u0433\u0440\u0430\u0444\u0430 \u0438 \u0441\u0440\u0435\u0434\u043d\u044e\u044e \u0434\u043b\u0438\u043d\u0443 \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0435\u0433\u043e \u043f\u0443\u0442\u0438. \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043d\u043e\u0432\u043e \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0442\u044c \u043a\u043e\u0434 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0438\u043b\u0438 \u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043d\u0435\u0441\u043c\u0435\u0436\u043d\u044b\u0445 \u0441\u0432\u044f\u0437\u0435\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u0418\u0437\u043b\u0438 \u0438 \u041a\u043b\u0435\u0439\u043d\u0431\u0435\u0440\u0433 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442, \u0447\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u044c \u00ab\u043c\u0438\u0440 \u0442\u0435\u0441\u0435\u043d\u00bb \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u0430\u0436\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043c\u0435\u0436\u043d\u044b\u0435 \u0441\u0432\u044f\u0437\u0438. \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043d\u0435\u0441\u043c\u0435\u0436\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u0438 \u0434\u043b\u044f \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0443\u0437\u043b\u043e\u0432 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0443\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0434\u043b\u0438\u043d\u0443 \u043f\u0443\u0442\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u0443\u0437\u043b\u0430\u043c\u0438.<\/p>\n<p>\u00a0<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \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\/company\/piter\/blog\/680576\/\"> https:\/\/habr.com\/ru\/company\/piter\/blog\/680576\/<\/a><br \/><\/br><\/br><\/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-336506","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/336506","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=336506"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/336506\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=336506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=336506"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=336506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}