OrientDB: connected components OSQL query

2020-02-29 13:59发布

问题:

Does anybody know how to compute the connected components of a graph with an OrientDB query? I'm trying to replicate what was done here but I'm missing something similar to a REDUCE operator for collections.

Thanks in advance.

回答1:

This query

SELECT distinct(traversedElement(0)) 
FROM (TRAVERSE both('ManagedBy') FROM Employee)

Returned me the right result. At the beginning I could not understand why but then I figured out that the default strategy used in TRAVERSE is DFS that's why we can rely on taking the first node of each traversal as a representative for its connected component.