def filter_graphs(graph_coverages, nodeset_size_limit):
    """
    Filter graphs if they exceed nodeset_size_limit.
    :param graph_coverages: Dictionary of SemanticGraph objects mapped to sets of coverage tuples
    :param nodeset_size_limit: Maximum size of graph node set
    :return: Filtered dictionary of SemanticGraph objects mapped to sets of coverage tuples
    """

    if nodeset_size_limit > 0:
        # The maximum nodeset size constraint is applied after all rules are created
        # This is to prevent restricting the space of possible rules

        final_graphs = filter(lambda x: len(x) <= nodeset_size_limit, graph_coverages.keys())

        return dict((graph, graph_coverages[graph]) for graph in final_graphs)

    else:
        return graph_coverages