def create_connectivity_list(shape, element_offset=0):
    """Use the element indices for each shape to create the connectivity list"""
    num_points = len(shape.points)
    num_parts = len(shape.parts)
    elements = []

    for i in range(num_parts):
        # parts[] returns the point index at the start of each part
        # These values will define the connectivity list of the line segments
        p1 = shape.parts[i]

        # Check to see if we're at the last part so we don't over index the list
        if i < num_parts - 1:
            p2 = shape.parts[i + 1] - 1
        else:
            p2 = num_points - 1

        p1 += element_offset
        p2 += element_offset

        # Create the connectivity list for this part. Each point is connected to the next
        for i in range(p1, p2):
            elements.append((i, i + 1))
    return elements