def build_streets_vertices(edges, shapes):
    """
    Returns vertices and edges based on the subset of edges.

    @param      edges       indexes
    @param      shapes      streets
    @return                 vertices, edges

    *vertices* is a list of points.
    *edges* is a list of `tuple(a, b)` where `a`, `b` are
    indices refering to the array of vertices
    """
    points = []
    for i in edges:
        p = shapes[i].points
        a, b = (p[0][0], p[0][1]), (p[-1][0], p[-1][1])
        points.append(a)
        points.append(b)
    vertices = list(sorted(set(points)))
    positions = {p: i for i, p in enumerate(vertices)}
    new_edges = []
    for i in edges:
        points = shapes[i].points
        a, b = (points[0][0], points[0][1]), (points[-1][0], points[-1][1])
        new_edges.append((positions[a], positions[b]))
    return vertices, new_edges