Returns all the edges between the vertexes iVertex1 and iVertex2.

@param iVertex1
First Vertex
@param iVertex2
Second Vertex
@return The Set with the common Edges between the two vertexes. If edges aren't found the set is empty
555792
public Set<ODocument> getEdgesBetweenVertexes(final ODocument iVertex1, final ODocument iVertex2) {
    return getEdgesBetweenVertexes(iVertex1, iVertex2, null, null);
  }
521926
public boolean isConnectedInDirection(
      DiGraphNode<N, E> dNode1,
      Predicate<E> edgeMatcher,
      DiGraphNode<N, E>  dNode2) {
    // Verify the nodes.
    List<DiGraphEdge<N, E>> outEdges = dNode1.getOutEdges();
    int outEdgesLen = outEdges.size();
    List<DiGraphEdge<N, E>> inEdges = dNode2.getInEdges();
    int inEdgesLen = inEdges.size();
    // It is possible that there is a large assymmetry between the nodes, so pick the direction
    // to search based on the shorter list since the edge lists should be symmetric.
    if (outEdgesLen < inEdgesLen) {
      for (int i = 0; i < outEdgesLen; i++) {
        DiGraphEdge<N, E> outEdge = outEdges.get(i);
        if (outEdge.getDestination() == dNode2
            && edgeMatcher.apply(outEdge.getValue())) {
          return true;
        }
      }
    } else {
      for (int i = 0; i < inEdgesLen; i++) {
        DiGraphEdge<N, E> inEdge = inEdges.get(i);
        if (inEdge.getSource() == dNode1
            && edgeMatcher.apply(inEdge.getValue())) {
          return true;
        }
      }
    }

    return false;
  }
676258
def equivalent(kls, first, second):
    
    if first.empty() and second.empty():
      return True
    elif first.vertices.shape[0] != second.vertices.shape[0]:
      return False
    elif first.edges.shape[0] != second.edges.shape[0]:
      return False

    EPSILON = 1e-7

    vertex1, inv1 = np.unique(first.vertices, axis=0, return_inverse=True)
    vertex2, inv2 = np.unique(second.vertices, axis=0, return_inverse=True)

    vertex_match = np.all(np.abs(vertex1 - vertex2) < EPSILON)
    if not vertex_match:
      return False

    remapping = {}
    for i in range(len(inv1)):
      remapping[inv1[i]] = inv2[i]
    remap = np.vectorize(lambda idx: remapping[idx])

    edges1 = np.sort(np.unique(first.edges, axis=0), axis=1)
    edges1 = edges1[np.lexsort(edges1[:,::-1].T)]

    edges2 = remap(second.edges)
    edges2 = np.sort(np.unique(edges2, axis=0), axis=1)
    edges2 = edges2[np.lexsort(edges2[:,::-1].T)]
    edges_match = np.all(edges1 == edges2)

    if not edges_match:
      return False

    second_verts = {}
    for i, vert in enumerate(second.vertices):
      second_verts[tuple(vert)] = i
    
    for i in range(len(first.radii)):
      i2 = second_verts[tuple(first.vertices[i])]

      if first.radii[i] != second.radii[i2]:
        return False

      if first.vertex_types[i] != second.vertex_types[i2]:
        return False

    return True
335392
function EdgeShape(v1, v2) {
  if (!(this instanceof EdgeShape)) {
    return new EdgeShape(v1, v2);
  }

  EdgeShape._super.call(this);

  this.m_type = EdgeShape.TYPE;
  this.m_radius = Settings.polygonRadius;

  // These are the edge vertices
  this.m_vertex1 = v1 ? Vec2.clone(v1) : Vec2.zero();
  this.m_vertex2 = v2 ? Vec2.clone(v2) : Vec2.zero();

  // Optional adjacent vertices. These are used for smooth collision.
  // Used by chain shape.
  this.m_vertex0 = Vec2.zero();
  this.m_vertex3 = Vec2.zero();
  this.m_hasVertex0 = false;
  this.m_hasVertex3 = false;
}
649984
public List vertexList() {
        List vertices = new ArrayList(edgeSet().size());

        Object startVertex = vertexSet().iterator().next();

        Object vertex = startVertex;
        Object previousVertex = null;
        Object nextVertex = null;

        while (nextVertex != startVertex) {
            assert (degreeOf(vertex) == 2);
            List edges = edgesOf(vertex);

            vertices.add(vertex);

            Edge edge = (Edge) edges.get(0);
            nextVertex = edge.oppositeVertex(vertex);

            if (nextVertex == previousVertex) {
                edge = (Edge) edges.get(1);
                nextVertex = edge.oppositeVertex(vertex);
            }

            previousVertex = vertex;
            vertex = nextVertex;

        }

        return vertices;
    }
987081
private IntIntPair[] sortEdges(int[] dindex) {
    IntIntPair[] edgesort = new IntIntPair[shared.layout.edges.size()];
    int e = 0;
    for(Layout.Edge edge : shared.layout.edges) {
      int i1 = dindex[edge.dim1], i2 = dindex[edge.dim2];
      edgesort[e] = new IntIntPair(Math.min(i1, i2), e);
      e++;
    }
    Arrays.sort(edgesort);
    return edgesort;
  }
874983
@Override
    public double similarity(Vertex<V> vertex1, Vertex<V> vertex2) {
        return similarity(vertex1.vertexID(), vertex2.vertexID());
    }
816746
private Pair<Integer, Integer> indexToEdgeBijection(long index) {
        long i = (long) Math.ceil((Math.sqrt(1 + 8 * (index + 1)) - 1) / 2);
        long diff = index + 1 - (i * (i - 1)) / 2;

        return Pair.of((int) i, (int) diff - 1);
    }
498804
@Nonnull
    public static <E> Set<E> union(@Nullable final Set<E> pColl1, @Nullable final Set<E> pColl2)
    {
        final Set<E> result = new HashSet<>();
        if (pColl1 != null) {
            result.addAll(pColl1);
        }
        if (pColl2 != null) {
            result.addAll(pColl2);
        }
        return Collections.unmodifiableSet(result);
    }
511861
public static int intersectionSize(DBIDs first, DBIDs second) {
    // If exactly one is a Set, use it as second parameter.
    if(second instanceof SetDBIDs) {
      if(!(first instanceof SetDBIDs)) {
        return internalIntersectionSize(first, second);
      }
    }
    else if(first instanceof SetDBIDs) {
      return internalIntersectionSize(second, first);
    }
    // Both are the same type: both set or both non set.
    // Smaller goes first.
    return first.size() <= second.size() ? internalIntersectionSize(first, second) : internalIntersectionSize(second, first);
  }
1027184
function getTJunctions (points, edges, edgeBounds, vertBounds) {
  var result = []
  boxIntersect(edgeBounds, vertBounds, function (i, v) {
    var e = edges[i]
    if (e[0] === v || e[1] === v) {
      return
    }
    var p = points[v]
    var a = points[e[0]]
    var b = points[e[1]]
    if (segseg(a, b, p, p)) {
      result.push([i, v])
    }
  })
  return result
}
1349322
@Override
    public void collate(VariantGraph graph, List<? extends Iterable<Token>> witnesses) {
        // phase 1: matching phase
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("Building token index from the tokens of all witnesses");
        }

        this.tokenIndex = new TokenIndex(comparator, witnesses);
        tokenIndex.prepare();

        // phase 2: alignment phase
        this.vertex_array = new VariantGraph.Vertex[tokenIndex.token_array.length];
        boolean firstWitness = true;

        for (Iterable<Token> tokens : witnesses) {
            final Witness witness = StreamUtil.stream(tokens)
                    .findFirst()
                    .map(Token::getWitness)
                    .orElseThrow(() -> new IllegalArgumentException("Empty witness"));

            // first witness has a fast path
            if (firstWitness) {
                super.merge(graph, tokens, Collections.emptyMap());
                updateTokenToVertexArray(tokens, witness);
                firstWitness = false;
                continue;
            }

            // align second, third, fourth witness etc.
            if (LOG.isLoggable(Level.FINER)) {
                LOG.log(Level.FINER, "{0} + {1}: {2} vs. {3}", new Object[]{graph, witness, graph.vertices(), tokens});
            }

            // Phase 2a: Gather matches from the token index
            if (LOG.isLoggable(Level.FINE)) {
                LOG.log(Level.FINE, "{0} + {1}: Gather matches between variant graph and witness from token index", new Object[]{graph, witness});
            }

            allPossibleIslands = TokenIndexToMatches.createMatches(tokenIndex, vertex_array, graph, tokens);

            if (LOG.isLoggable(Level.FINE)) {
                LOG.log(Level.FINE, "{0} + {1}: Aligning witness and graph", new Object[]{graph, witness});
            }

            // Phase 2b: do the actual alignment
            IslandConflictResolver resolver = new IslandConflictResolver(new IslandCollection(allPossibleIslands));
            preferredIslands = resolver.createNonConflictingVersion().getIslands();

            // we need to convert the islands into Map<Token, Vertex> for further processing
            Map<Token, VariantGraph.Vertex> alignments = new HashMap<>();
            for (Island island : preferredIslands) {
                for (Coordinate c : island) {
                    alignments.put(c.match.token, c.match.vertex);
                }
            }

            if (LOG.isLoggable(Level.FINER)) {
                for (Map.Entry<Token, VariantGraph.Vertex> tokenLink : alignments.entrySet()) {
                    LOG.log(Level.FINER, "{0} + {1}: Aligned token (incl transposed): {2} = {3}", new Object[]{graph, witness, tokenLink.getValue(), tokenLink.getKey()});
                }
            }

            if (LOG.isLoggable(Level.FINE)) {
                LOG.log(Level.FINE, "{0} + {1}: Detect phrase matches", new Object[]{graph, witness});
            }

            // Phase 2c: detect phrases and transpositions
            phraseMatches = phraseMatchDetector.detect(alignments, graph, tokens);

            if (LOG.isLoggable(Level.FINER)) {
                for (List<Match> phraseMatch : phraseMatches) {
                    LOG.log(Level.FINER, "{0} + {1}: Phrase match: {2}", new Object[]{graph, witness, phraseMatch});
                }
            }

            if (LOG.isLoggable(Level.FINE)) {
                LOG.log(Level.FINE, "{0} + {1}: Detect transpositions", new Object[]{graph, witness});
            }

            transpositions = transpositionDetector.detect(phraseMatches, graph);

            if (LOG.isLoggable(Level.FINE)) {
                LOG.log(Level.FINE, "transpositions:{0}", transpositions);
            }

            if (LOG.isLoggable(Level.FINER)) {
                for (List<Match> transposition : transpositions) {
                    LOG.log(Level.FINER, "{0} + {1}: Transposition: {2}", new Object[]{graph, witness, transposition});
                }
            }

            if (LOG.isLoggable(Level.FINE)) {
                LOG.log(Level.FINE, "{0} + {1}: Determine aligned tokens by filtering transpositions", new Object[]{graph, witness});
            }

            // Filter out transposed tokens from aligned tokens
            for (List<Match> transposedPhrase : transpositions) {
                for (Match match : transposedPhrase) {
                    alignments.remove(match.token);
                }
            }

            if (LOG.isLoggable(Level.FINER)) {
                for (Map.Entry<Token, VariantGraph.Vertex> alignment : alignments.entrySet()) {
                    LOG.log(Level.FINER, "{0} + {1}: Alignment: {2} = {3}", new Object[]{graph, witness, alignment.getValue(), alignment.getKey()});
                }
            }

            // Phase 2d: and merge
            merge(graph, tokens, alignments);

            // we filter out small transposed phrases over large distances
            List<List<Match>> falseTranspositions = new ArrayList<>();

            // rank the variant graph
            VariantGraphRanking ranking = VariantGraphRanking.of(graph);

            for (List<Match> transposedPhrase : transpositions) {
                Match match = transposedPhrase.get(0);
                VariantGraph.Vertex v1 = witnessTokenVertices.get(match.token);
                VariantGraph.Vertex v2 = match.vertex;
                int distance = Math.abs(ranking.apply(v1) - ranking.apply(v2)) - 1;
                if (distance > transposedPhrase.size() * 3) {
                    falseTranspositions.add(transposedPhrase);
                }
            }

            transpositions.removeAll(falseTranspositions);

            // merge transpositions
            if (mergeTranspositions) {
                mergeTranspositions(graph, transpositions);
            }

            updateTokenToVertexArray(tokens, witness);

            if (LOG.isLoggable(Level.FINER)) {
                LOG.log(Level.FINER, "!{0}: {1}", new Object[]{graph, StreamUtil.stream(graph.vertices()).map(Object::toString).collect(Collectors.joining(", "))});
            }
        }
    }
309734
public static <E> Set<E> union(final Set<? extends E> set1, final Set<? extends E> set2) {
        checkArgumentNotNull(set1, "set1");
        checkArgumentNotNull(set2, "set2");

        // Set 2 minus set 1
        final Set<E> difference = new HashSet<>(set2);
        difference.removeAll(set1);
        // Following stream does not compile on some JDKs
        // See also https://bugs.openjdk.java.net/browse/JDK-8051443
        // set2.stream().filter((e) -> !set1.contains(e)).collect(Collectors.toSet());

        return new AbstractSet<E>() {

            @Override
            public Iterator<E> iterator() {
                final Iterator<E> iterator = Iterators.concat(ImmutableList.of(set1.iterator(), difference.iterator()).iterator());
                // Remove operation is not supported by default
                return new Iterator<E>() {
                    @Override
                    public boolean hasNext() {
                        return iterator.hasNext();
                    }

                    @Override
                    public E next() {
                        return iterator.next();
                    }
                };
            }

            @Override
            public int size() {
                return set1.size() + difference.size();
            }

            @Override
            public boolean isEmpty() {
                return set1.isEmpty() && difference.isEmpty();
            }

            @Override
            public boolean contains(Object o) {
                return set1.contains(o) || difference.contains(o);
            }
        };
    }
1222069
public static double jaccardIndex(DoubleVector a, DoubleVector b) {
        Set<Double> intersection = new HashSet<Double>();
        Set<Double> union = new HashSet<Double>();
        for (int i = 0; i < a.length(); ++i) {
            double d = a.get(i);
            intersection.add(d);
            union.add(d);
        }
        Set<Double> tmp = new HashSet<Double>();
        for (int i = 0; i < b.length(); ++i) {
            double d = b.get(i);
            tmp.add(d);
            union.add(d);
        }

        intersection.retainAll(tmp);
        return ((double)(intersection.size())) / union.size();
    }
55371
public static <E> Set<E> unionView(final Set<? extends E> set1, final Set<? extends E> set2) {
		return Sets.union(set1, set2);
	}
894461
public static ConceptId getResourceEdgeId(TransactionOLTP graph, ConceptId conceptId1, ConceptId conceptId2) {
        if (mayHaveResourceEdge(graph, conceptId1, conceptId2)) {
            Optional<Concept> firstConcept = graph.stream(Graql.match(
                    var("x").id(conceptId1.getValue()),
                    var("y").id(conceptId2.getValue()),
                    var("z").rel(var("x")).rel(var("y")))
                    .get("z"))
                    .map(answer -> answer.get("z"))
                    .findFirst();
            if (firstConcept.isPresent()) {
                return firstConcept.get().id();
            }
        }
        return null;
    }
666582
public static <T> Collection<T> intersection(Collection<T> coll1, Collection<T> coll2) {
		final ArrayList<T> list = new ArrayList<>();
		if (isNotEmpty(coll1) && isNotEmpty(coll2)) {
			final Map<T, Integer> map1 = countMap(coll1);
			final Map<T, Integer> map2 = countMap(coll2);
			final Set<T> elts = newHashSet(coll2);
			int m;
			for (T t : elts) {
				m = Math.min(Convert.toInt(map1.get(t), 0), Convert.toInt(map2.get(t), 0));
				for (int i = 0; i < m; i++) {
					list.add(t);
				}
			}
		}
		return list;
	}