import copy


def to_undirected(graph):
    """
        If A -> B, B -> A is also created
    :param graph:
    :return:
    """
    new_graph = {}
    for node, neighbors in graph.items():
        if node not in new_graph:
            new_graph[node] = {}
        for n, attr in neighbors.items():
            if n not in new_graph:
                new_graph[n] = {}
            new_graph[node][n] = copy.deepcopy(attr)
            new_graph[n][node] = copy.deepcopy(attr)
    return new_graph