def missing_edges(x, y):
    """
	Counts edges that are present in the original structure (x) but
	are missing in the learned structure (y). (lower is better)
	"""
    missing = 0
    for rv in x.nodes():
        if not y.has_node(rv):
            missing += x.degree(rv)
        else:
            for child in x.children(rv):
                if child not in y.children(rv):
                    missing += 1
    return missing
