Beispiel #1
0
  @Override
  public Iterable<String> findRelatedEdges(
      Iterable<String> vertexIds, Authorizations authorizations) {
    Set<String> results = new HashSet<String>();
    List<Vertex> vertices = toList(getVertices(vertexIds, authorizations));

    // since we are checking bi-directional edges we should only have to check v1->v2 and not v2->v1
    Map<String, String> checkedCombinations = new HashMap<String, String>();

    for (Vertex sourceVertex : vertices) {
      for (Vertex destVertex : vertices) {
        if (checkedCombinations.containsKey(sourceVertex.getId() + destVertex.getId())) {
          continue;
        }
        Iterable<String> edgeIds =
            sourceVertex.getEdgeIds(destVertex, Direction.BOTH, authorizations);
        for (String edgeId : edgeIds) {
          results.add(edgeId);
        }
        checkedCombinations.put(sourceVertex.getId() + destVertex.getId(), "");
        checkedCombinations.put(destVertex.getId() + sourceVertex.getId(), "");
      }
    }
    return results;
  }