@VisibleForTesting
  public static Set<Vertex> getVertices(List<Edge> edges) {
    Set<Vertex> vertices = new LinkedHashSet<Vertex>();
    for (Edge edge: edges) {
      vertices.addAll(edge.targets);
    }
    for (Edge edge: edges) {
      vertices.addAll(edge.sources);
    }

    // Assign ids to all vertices,
    // targets at first, then sources.
    int id = 0;
    for (Vertex vertex: vertices) {
      vertex.id = id++;
    }
    return vertices;
  }
Get all the vertices of all edges. Targets at first,
then sources. Assign id to each vertex.
ql/src/java/org/apache/hadoop/hive/ql/hooks/LineageLogger.java