def incorrect_direction_edges(x,y):
	"""
	Counts directed edges in the learned structure
	that are oriented incorrectly. (lower is better)
	"""
	incorrect_direction = 0
	for rv in x.nodes():
		if x.has_node(rv):
			for child in x.children(rv): # child is rv's child in x
				if rv in y.parents(rv): # child is rv's parent in y
					incorrect_direction += 1
	return incorrect_direction