similar edges and how to prevent them


yair...@...
 


I have an app where I am migration a d non graph DB graph to Janus. So I create the graph when I first start the app. Using cassandra backend.

I have an issue where 2 vertices have "identical" edges (besides the auto-generated id of course) are created in my code causing me to get too many IN and OUT edges.

I read my vertex like this:


javaGraph.traversal().V().hasLabel(instanceId).has("nodeId", lineageNodeId).toList();




I read Both edges:

vertex.edges(org.apache.tinkerpop.gremlin.structure.Direction.IN, "link");


vertex
.edges(org.apache.tinkerpop.gremlin.structure.Direction.OUT, "link");


each time I run my app it doesn't "see" the existing edges and adds to it. so I get edges multiplies while I only want "link" edge between any 2 given vertices

in order to make sure I don't create duplicate vertices:


        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;
        }



But I don't know once I have vertex A and B at hand - how to verify they are not already connected.






Join janusgraph-users@lists.lfaidata.foundation to automatically receive all group messages.