def METHOD_NAME(meshes, gates, result):
    '''calculate connexions by creating sets'''
    for vertices, edges, item_n, distance in zip(*meshes):
        if gates[3]:
            item_n = [i for i, m in enumerate(item_n) if m]
        connexions_dict = {}
        connexions_dict[0] = item_n
        d_max = max(distance)
        _ = all_connexions(edges, item_n, d_max, connexions_dict, d_max)
        out_index = []
        for d in distance:
            if d in connexions_dict:
                out_index += connexions_dict[d]
        out_index = list(set(out_index))
        result[0].append(out_index)
        if gates[1]:
            connected_v = []
            for i in out_index:
                connected_v.append(vertices[i])
            result[1].append(connected_v)
        if gates[2]:
            mask = [i in out_index for i in range(len(vertices))]
            result[2].append(mask)
    return result