Search code examples
orientdbgraph-theorygremlingraph-traversal

Graph traversal based on value of property of Edge | OrientDB


I have a graph which save topology of cloud infrastructure of a firm.It consists of Vertex called Object (Machines) and Edge called link (to denote how machines are linked to each other these links keep changing according as one machine can connect to different machines depending on need).

create class Object extends V

create class link extends E

Object vertices denotes Machine have properties to store config of the machine.

create property Object.ram long

create property Object.mem long

create property Object.cpu_core long

"link" edges links machine together to form a topology.It is a outbound edge from one machine to other. It has two time based property startTime which denotes the when this edge was created between two machines and endTime which initially is infinity and is update if we need to close this edge denoting that two machine and now no more linked.

create property link.startTime long

create property link.endTime long

create property link.l_id string

I want traverse from a Object(vertex) to all its connected Objects imposing a condition on link(edge) property while traversing that for a time say t, should be startTime <= t <= endTime.

For example Topology (Please click the link ) I want to traverse down from node rid #21:0 to all the edges using link edges whose startTime > 1488965393 and endTime < 1498965393. I am quite new to OrientDB and not able to figure out possible SQL command for the same.

Pseudo query (looking for something similar if possible):

SELECT *  FROM (TRAVERSE out('link') FROM #21:0 while startTime > 1488965393 and endTime < 1498965393) 

Solution

  • I was able to form a query that produced the desired output

    SELECT id FORM (TRAVERSE out() FROM #21:0 WHILE (creationTime<= 1488965393 AND endTime >= 1488965393 AND @class='link')) WHERE @class= 'Object'