cap_corridor function

Cap the corridor by connecting the edge end points