Implemented hamilton cycle.