Member-only story
out() vs. outE() — JanusGraph and Gremlin
If you are new to JanusGraph and the Gremlin query language, like I am, you would be confused about the out()
, outE()
, in()
, and inE()
methods. If you look at examples of these functions, you'll not be able to comprehend the difference easily. Or is it just me?
Anyway, I got confused and it took me a while to understand there is a difference, and there isn’t. Let me explain.
The Sample Graph
Before we look at the differences, let’s look at a sample graph.
As you can see from the graph above, we have four vertices and three edges. The vertex in the middle with the property "name": "sunny"
is the vertex from where we'll start our traversal. The other three vertices are the items that I bought from an e-commerce website. They are a smartphone, a laptop, and a monitor. The relationship is represented with edges labelled bought
.
The edges have another property called count
, and as you can tell, they represent the number of times I have bought these items. So I bought three smartphones, two laptops, and one monitor. This is the data we're going to work with.
Now, we’ll first get a reference to our starting vertex with the following query:
sunny = g.V().has('name', 'sunny').next()