added type information to weighted_graph function