如何在 OrientDB 中计算连通分量

How to compute connected components in OrientDB

OrientDB 是否支持 connected components 的高效计算?

我没有使用图形数据库的经验。我天真的直觉是这个操作应该是相当高效的。

如果它得到有效支持,查询将如何查找所有连接的组件?

以下是 OrientDB website 的节选。我已经突出显示了一些相关部分。

OrientDB can embed documents like any other document database, but also supports relationships. It doesn’t use the costly JOIN. Instead, OrientDB uses super-fast, persistent pointers between records, taken from the graph database world. You can traverse parts of or entire trees and graphs of records in just a few milliseconds.

This illustration shows how the original document has been split into two documents linked using the Customer’s Record ID #8:124 to connect the Order to the Customer document. Links can be thought of as in-memory pointers, but persistent on disk.

[snip]

Equipped With document and relational DBMS, the more data you have, the slower the database will be. Joins have a heavy runtime cost. Instead, OrientDB handles relationships as physical links to the records, assigned only once, when the edge is created O(1). Compare this to an RDBMS that “computes“ the relationship every single time you query a database O(LogN). With OrientDB, traversing speed is not affected by the database size. It is always constant, whether for one record or 100 billion records. This is critical in the age of Big Data!

这里是取自 tutorial document 的示例查询,它将获取名为 Luca 的人的所有朋友。

SELECT EXPAND( BOTH( 'Friend' ) ) FROM Person WHERE name = 'Luca'

我遇到了同样的问题,但我最终写了一个 OSQL 查询来计算图中的连通分量,这里是