Selecting edges for ShortestPath

114 views
Skip to first unread message

Ricardo A. Pasquini

unread,
Nov 21, 2015, 11:42:02 AM11/21/15
to OrientDB
Hi Orientdb community,
I have a graph with dates as propertys in the edges. In my case, for instance, I have employees and companys as vertices, and an edge class (say Workin) represents that an employee X works in company Y since a specific date. For instance:

Employee X-> Workin (since May 2010)> Company Y
 
I am studying how the paths have evolved in time. I am interested in a historical analysis of the network. Precisely I would like to compute shortest paths in my graph by restricting the edges to certain dates. 
I am aware that the ShortestPath function allows traversing edges only from a specific class, but not  filtering edges with a certain condition in their properties. Is there a way to do this?

I have thought two possible solutions but I am not happy yet with either of them. One is to create involving only the relationships I am interested for certain dates. However, I do not know here how to easily assign a set of edges to a new class. It will also have the cost of having a high number of classes for the dates I am interested in.
The other solution I thought is to play with the dijkstra() function, giving extremely high values to certain edges when in reality they do not exist.
I was wondering if any of you could 
Thanks in advance
Ricardo

Ricardo A. Pasquini

unread,
Nov 23, 2015, 5:46:06 PM11/23/15
to OrientDB
Let me rephrase the question: Is it possible to select a ShortestPath from a graph where edges have a specific edge property? 

Luca Garulli

unread,
Nov 23, 2015, 8:49:17 PM11/23/15
to OrientDB
Hi Ricardo,
Yes, it's called dijkstra. Look at:


Best Regards,

Luca Garulli
Founder & CEO


--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

scott molinari

unread,
Nov 24, 2015, 12:27:56 AM11/24/15
to OrientDB
I believe Ricardo is looking for something like

SELECT shortestPath(#8:32, #8:10) WHERE Workin = "2010-05-01"

Scott

Luca Garulli

unread,
Nov 24, 2015, 7:27:55 AM11/24/15
to OrientDB
The only function that works out of the box is dijkstra(), otherwise you could write your own function that is optimized for your case. you could write it in Javascript under OrientDB Server function and then call it from SQL:

select myShortestPath(#8:32, #8:10, "2010-05-01")

Best Regards,

Luca Garulli
Founder & CEO


--

Ricardo A. Pasquini

unread,
Nov 24, 2015, 8:26:10 AM11/24/15
to OrientDB
Thanks very much Scott and Luca. Yes, indeed I am looking for something more like:

SELECT shortestPath(#8:32, #8:10, 'both', Workin.date="2010-05-01")

Which would involve first selecting a graph (edges) that exist in a given date, and second obtaining the shortest path for that specific graph.
I will write a function in Javascript as Luca suggests. Since I have so many dates the optimization is key. I will let you know what best solution I can find.
Thanks a lot, and regards

Ricardo Pasquini

Luca Garulli

unread,
Nov 24, 2015, 8:36:51 PM11/24/15
to OrientDB
Hi Ricardo,

I was thinking about your proposal:

SELECT shortestPath(#8:32, #8:10, 'both', Workin.date="2010-05-01")

And I found something easy to implement:

SELECT shortestPath(#8:32, #8:10, 'both', ( Workin.date="2010-05-01") )

With parenthesis, we could easily parse the expression and apply it. Could you open a new issue for that? Unfortunately we're super busy to release v2.2.0-rc1 and this feature could be implemented not before a couple of months.


Best Regards,

Luca Garulli
Founder & CEO


Reply all
Reply to author
Forward
0 new messages