fixes to weighted_graph crashing