Get Edges Between Vertices (Again)

57 views
Skip to first unread message

John J. Szucs

unread,
Mar 16, 2017, 6:18:39 AM3/16/17
to OrientDB
I need to *very quickly* find the edges that directly connect two specified vertices, using either a SQL query, the Java API, or a combination of the two. If it helps, at this point in the program, I know for a fact that the two vertices are adjacent. What I'm trying to determine is how they are adjacent.

The OrientVertex.getEdges(OrientVertex, Direction, String ...) extension to the Blueprints API does what I need to do functionally, but it can be quite slow if the first vertex has many edges. Looking into the source code, I found that this is because this method essentially gets *all* of the edges from the first vertex that match the direction and label criteria and then checks if they are adjacent (connect to) the second vertex.

I have struggled with this for days. Does anyone have a better/faster approach?

Thanks!

-- John

Luigi Dell'Aquila

unread,
Mar 16, 2017, 7:24:33 AM3/16/17
to orient-...@googlegroups.com
Hi John,

you have two alternatives:

1) use OrientVertex.countEdges() to check which of the two vertices has a smaller number of edges. This approach is good if you know that at most one is a supernode

2) if you know that both vertices can be supernodes, then the only efficient way to find the edge is to define and index on edge(out, in) and do the indexed query directly

I hope it helps

Thanks

Luigi


--

---
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-database+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

John J. Szucs

unread,
Mar 16, 2017, 7:43:21 AM3/16/17
to orient-...@googlegroups.com
Luigi,

Yes, this helps. Your option #2 is more applicable to my project.

Will OrientDB 3.0 significantly change/improve this use case? I don't want to implement this manual edge index if it will become unnecessary in (a few?) weeks.

Thanks!

-- John
You received this message because you are subscribed to a topic in the Google Groups "OrientDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orient-database/yyivlLcoS6A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orient-databa...@googlegroups.com.

Luigi Dell'Aquila

unread,
Mar 16, 2017, 9:46:57 AM3/16/17
to orient-...@googlegroups.com
Hi John,

In MATCH statement (2.2) and more in general in 3.0 we are changing the optimization of queries based on indexes, but you will still need an index on the edge for such use case, so the big part of the work will be needed anyway. 

Thanks

Luigi


To unsubscribe from this group and all its topics, send an email to orient-database+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

John J. Szucs

unread,
Mar 20, 2017, 12:09:03 AM3/20/17
to OrientDB
Luigi,

To close this out, I implemented your Option #2 suggestion. I found at very good example at http://stackoverflow.com/questions/32953396/orientdb-edge-index-via-java and the results are absolutely spectacular!

Thanks for your help!

BTW: We will soon be launching our technology, which uses OrientDB for natural language processing and Semantic Web applications, on the Web. When we do, I will definitely write up a case study for you, Luca, and the other folks at OrientDB whose help has been so essential. And when we get investment or gain some traction (users, licensees, etc.) I look forward to buying a real license, support contract, etc. because that's a win-win for all of us!

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

--

---
You received this message because you are subscribed to a topic in the Google Groups "OrientDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orient-database/yyivlLcoS6A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orient-databa...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

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

Luigi Dell'Aquila

unread,
Mar 20, 2017, 6:07:03 AM3/20/17
to orient-...@googlegroups.com
Hi John,

Happy to see it helped. Keep us posted the progress of your project!!!

Thanks

Luigi


To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages