def factors_to_undirected_graph(factors):
    """
    Represent factor graph as undirected graph

    Inputs:
    -------

    List of factors

    Output:
    -------

    Undirected graph as dictionary of edges mapped to the factor from
            which edge originates
    """
    edges = {}
    for factor_ix, factor in enumerate(factors):
        factor_set = set(factor)
        for v1 in factor:
            for v2 in (factor_set - set([v1])):
                edges.setdefault(frozenset((v1, v2)), set())
                edges[frozenset((v1, v2))].add(factor_ix)
    return edges
