adding a generalized hamming distance for differences between weighted graphs and a potentially different cost for non-relations and zero relations.