memoized is_locally_two_connected