import copy


def copy_graph(g):
    """
    Create a copy of the given graph.

    :param g: input graph as dictionary
    :return: a copy of the graph
    >>> copy_graph({'edgeSet': [{'right':[4,5,6]}], 'entities': [], 'tokens':[]}) == {'edgeSet': [{'right':[4,5,6]}], 'entities': [], 'tokens':[]}
    True
    >>> copy_graph({}) == {'edgeSet':[], 'entities':[]}
    True
    """
    new_g = {'edgeSet': copy.deepcopy(g.get('edgeSet', [])),
             'entities': copy.copy(g.get('entities', []))}
    if 'tokens' in g:
        new_g['tokens'] = g.get('tokens', [])
    if 'filter' in g:
        new_g['filter'] = g['filter']
    return new_g