问题
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.
来源:https://stackoverflow.com/questions/33654067/orientdb-connected-components-osql-query