0

So I am having trouble how I would convert a nodeTraversal into Hashset.

GraphTraversal<vertex, vertex>nodeTraversal = this.central.V().has(nodeid).in("node").values(nodeId);

So far I have: GraphTraverl<vertex, vertex>nodeTraversal that returns the values of ids. I want to then convert that to a set by doing .toSet(), but get a cannot convert set<Object> to set<String>. I try to add a .join(',') like the tinkerpop docs but not luck.

Anyone know why?

1 Answer 1

0

I assume this is just an issue with getting the generics right. You've created nodeTraversal with <Vertex, Vertex> but that's technically not what you're returning. the outgoing object from nodeTraversal (i.e. the second Vertex generic definition) is not a Vertex but the data type of whatever the property given to values() is. Let's assume it was a String. Your code would look like:

GraphTraversal<Vertex, String> nodeTraversal = g.V().has("x").in("node").values("y");
Set<String> ids = nodeTraversal.toSet();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.