Search code examples
orientdbconnected-components

OrientDB: connected components OSQL query


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.


Solution

  • 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.