Add weak_ptr usage to resolve edge_t destruction.