本文介绍了Graph DB在未指定的终端节点上能否表现良好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在针对一个非常特定的场景对neo4j进行实验,但是我一直无法使其表现良好-查询需要几分钟才能返回.我想知道这是否是针对这项工作的错误技术?

I have been experimenting with neo4j for a very specific scenario and I have been unable to get it to perform well - queries take minutes to return. I am wondering if this is a case of the wrong technology for the job?

下面是我的情况的简化版本.我有 Town ,它们通过路线相互链接.每条路线都有一段距离.

A simplified version of my scenario is below. I have Towns that are linked to each other via routes. Each route has a distance.

我要问的问题是:计算从 Town A 到从 Town A 可以到达的每个其他城镇的最短路线.在这种情况下,没有指定数量的终端节点.该查询需要几分钟才能返回一个较小的数据集,而对于具有50,000个节点的较大数据集则根本不会返回.

The question I'm trying to ask is: calculate the shortest route from Town A to every other town reachable from Town A. In this scenario, there are an unspecified number of end nodes. This query takes minutes to return with a small dataset and doesn't return at all for larger data sets with 50,000 nodes.

如果我问一个问题:计算从 Town A Town E 的最短路径,响应似乎是即时的.在这种情况下,起始节点和结束节点都是已知的.

If I ask the question: calculate the shortest route from Town A to Town E the response is seemingly instant. In this scenario, both the start and end nodes are known.

我的问题是,图dbs是否适合开放式问题(计算从 Town A 到从 Town A 可以到达的每个其他城镇的最短路径)?如果是这样,难道是我构造数据的方法会影响性能吗?

My question is, are graph dbs good for the open ended questions (calculate the shortest route from Town A to every other town reachable from Town A)? If so, is it just my approach to structuring the data that is hampering the performance?

推荐答案

您的数据结构看起来不错(也许您可以添加带有"ROAD"边缘的"Intersection"顶点,其长度存储在ROAD边缘上,但是不确定是否有可用的数据),是的,这绝对是图形的好用例.

Your data structure looks good (maybe you could add an "Intersection" vertex with a "ROAD" edge with a length stored on the ROAD edge, but not sure what data you have available) and YES this is most definitely a good use case for graphs.

我不太使用Neoj4,但是问题很可能是您所使用的算法(查询)所采用的方法.

I haven't used Neoj4 much, but the problem most likely is the approach you are taking with the algorithm (query) involved.

Neo4j应该轻松处理您要完成的任务.我建议您观看一些有关该主题的Neo4j视频,并模仿它们采用最短路径算法的方法.

Neo4j should easily handle what you're looking to accomplish. I would recommend watching some Neo4j videos on the topic and mimic their approach to the shortest path algorithms.

Neo4j(最短路径): https://youtu.be/baEeRfuK1Nk

Neo4j(Shortest-Path): https://youtu.be/baEeRfuK1Nk

我一直用于实现这些功能的图形数据库一直在TigerGraph上,但是所有图形数据库将能够快速处理50,000个节点.

The graph database I've always used to implement these has always been on TigerGraph, but all graph databases would be able to handle 50,000 nodes quickly.

TigerGraph(最短路径): https://youtu.be/Ra0qORVKsWs

TigerGraph (Shortest-Path): https://youtu.be/Ra0qORVKsWs

已编辑(添加文档链接):

NEO4J

单源最短路径算法

文档: https://neo4j.com/docs/graph-algorithms/current/labs-algorithms/single-source-shortest-path/

老虎图

单源最短路径(未加权)

文档: https://docs.tigergraph.com/v/2.6/graph-algorithm-library#single-source-shortest-path-unweighted

代码: https://github.com/tigergraph/gsql-graph-algorithms/blob/master/algorithms/schema-free/shortest_ss_no_wt.gsql

单源最短路径(加权)

文档: https://docs.tigergraph.com/v/2.6/graph-algorithm-library#single-source-shortest-path-weighted

代码: https://github.com/tigergraph/gsql-graph-algorithms/blob/master/algorithms/schema-free/shortest_ss_any_wt.gsql

这篇关于Graph DB在未指定的终端节点上能否表现良好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 05:54