Using the tinkerpop blueprints API , what is the best way to find if a border exists between two vertices? I would like to avoid vertex.getEdges() and repeat until I find the right one.
For example: check if v1 friend of v2
Vertex v1 = g.addVertex(null); Vertex v2 = g.addVertex(null); Edge edge = g.addEdge(null, v1, v2, "friends"); Edge edge = g.addEdge(null, v1, v2, "follows"); // Node with lots of edges - Supernode - problem? List<Edge> edges = new ArrayList<Edge>(); for(Edge edge : g.getVertex(v1.getId()).getEdges(Direction.OUT, "friends")){ if(edge.getVertex(Direction.IN).getId().equals(v2.getId()){ edges.add(edge); } }
Should I use Vertex Query ?
Through gremlin I could do:
gv(v1.getID()).outE("friends").inV.filter{it.id == v2.getID}
Neo4j method:
IndexHits<Relationship> relationships = relationshipIndex().get("type", edgeType, node1, node2);
Thanks for the help! I am still new to this.
source share