fix bugs on add_edge