javaGraph.traversal().V().hasLabel(instanceId).has("nodeId", lineageNodeId).toList();vertex.edges(org.apache.tinkerpop.gremlin.structure.Direction.IN, "link");
vertex.edges(org.apache.tinkerpop.gremlin.structure.Direction.OUT, "link");
GraphTraversal<Vertex, Vertex> vertexNode = javaGraph.traversal().V().hasLabel(instanceId).has("nodeId", myNodeId); if (vertexNode.hasNext()) { return vertexNode.next(); } else {
JanusGraphVertex node = javaGraph.addVertex(instanceId); node.property("nodeId", myNodeId); return node; }
Iterator<Edge> edgesIter = from.edges(Direction.OUT, "link");
while (edgesIter.hasNext()) {
Edge edge = edgesIter.next();
Vertex outVertex = edge.outVertex();
if(outVertex.property("nodeId").value().equals(to.property("nodeId").value())){
return edge;
}
}
org.apache.tinkerpop.gremlin.structure.Edge linkedEdge = from.addEdge("link", to);
return linkedEdge;g.V().has(instanceId, "nodeId", nodeA).as("a").V().has(instanceId, "nodeId", nodeB).coalesce(bothE("link").where(otherV().as("a")),addE("link").to("a"))
g.V().has(instanceId, "nodeId", nodeA).as("a").V().has(instanceId, "nodeId", nodeB).coalesce(outE("link").where(inV().as("a")),inE("link").where(outV().as("a")),addE("link").to("a"))
--
You received this message because you are subscribed to the Google Groups "JanusGraph users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/janusgraph-users/020a1758-af67-4510-9860-90bc7b470709%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
g.V().hasLabel("V1")
.has("userId", userId).fold()
.coalesce(
unfold(),
addV("V1").property("userId", userId1)
).as("a")
.V().hasLabel("V1").has("userId", userId2).fold()
.coalesce(
unfold(),
addV("V1").property("userId", userId2)
)
.coalesce(
bothE("link").where(outV().as("a")),
addE("link").from("a")
)I guess the point is, that the edge's direction doesn't matter. Hence it should be more like:g.V().has(instanceId, "nodeId", nodeA).as("a").V().has(instanceId, "nodeId", nodeB).coalesce(bothE("link").where(otherV().as("a")),addE("link").to("a"))...or, if performance matters, don't enable path computations (using otherV):g.V().has(instanceId, "nodeId", nodeA).as("a").V().has(instanceId, "nodeId", nodeB).coalesce(outE("link").where(inV().as("a")),inE("link").where(outV().as("a")),addE("link").to("a"))Cheers,Daniel
On Mon, Sep 11, 2017 at 3:32 AM, <tpr...@gmail.com> wrote:
You can use coalesce step to do a check or insert query.
http://tinkerpop.apache.org/docs/current/reference/#coalesce-step
Something like g.V(idTo).as('to').V(idFrom).coalesce(__.outE('labelE').has('id',idValue),
__.addE('labelE').property('id',idvalue).to('to'))
--
You received this message because you are subscribed to the Google Groups "JanusGraph users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-use...@googlegroups.com.
g.V().has("V1","userId", userId).fold().coalesce(unfold(),
addV("V1").property("userId", userId1)).as("a").
map(V().has("V1","userId", userId2).fold()).coalesce(unfold(),addV("V1").property("userId", userId2))coalesce(bothE("link").where(outV().as("a")),
addE("link").from("a"))
To post to this group, send email to janusgra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/janusgraph-users/62aef11f-6934-457b-8942-667168d0488b%40googlegroups.com.