简体   繁体   中英

Gremlin: Select Vertices that have edges that share a property

This is in gremlin-scala. I have the traversal at a Vertex point (which is what '_' stands for below:

 _.as("vertex").outE().as("outEdge").in().inE().as("inEdge")
.select("inEdge","outEdge").by("fullName")
.where("inEdge", P.eq("outEdge")).select("vertex")

But I am getting an error referencing the .in() after the .as("outEdge") statement:

Error:(55, 40) Cannot prove that org.apache.tinkerpop.gremlin.structure.Edge <:< gremlin.scala.Vertex.

Can anyone help me figure out what is going wrong here, and more importantly, is this the correct way to find Vertices that have a matching property on its edges?

Thanks in advance.

I think that syntax is incorrect. Change:

_.as("vertex").outE().as("outEdge").in()

to

_.as("vertex").outE().as("outEdge").inV()

when you do outE() you are on an edge, so you must traverse to a Vertex which would be either inV() (the vertex adjacent to where you started), outV() (the vertex you started from since you traversed outE() , or bothV() which would yield both the vertices at either end of the edge.

I think your method for comparing properties makes sense. Someone else might post a way to simplify further.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM