def connectivity_dict_builder(edge_list, as_edges=False):
    """Builds connectivity dictionary for each vertex (node) - a list
    of connected nodes for each node.

    Args:
        edge_list (list): a list describing the connectivity
            e.g. [('E7', 'N3', 'N6'), ('E2', 'N9', 'N4'), ...]
        as_edges (bool): whether to return connected vertices / nodes or edges
    Returns:
        (dict): connectivity dictionary, each node is a key and the 
            value is a set of connected nodes
            e.g. {'N3': {'N6', 'N11', 'N7'}, 'N9': {'N4'}, etc}
    """
    connectivity_dict = {}
    for b, n1, n2 in edge_list:
        n_set = connectivity_dict.get(n1,set())
        n_set.add(b if as_edges else n2)
        connectivity_dict[n1] = n_set
        n_set = connectivity_dict.get(n2,set())
        n_set.add(b if as_edges else n1)
        connectivity_dict[n2] = n_set
    return connectivity_dict