as_weights_matrix function

Convert an object to a weights matrix