Deven Black was 62, and his life was falling apart. In a few short years, he had gone from respected, award-winning teacher to unemployed felon, losing his marriage and his home, moving into his car for a time and slipping into a depression that went largely untreated. He had nowhere to go.

Anthony White was only 21, and he had a plan. He was desperate to get his own apartment, but his low-paying job at J. C. Penney left him unable to pay any rent. He had his dreams, to be a famous rapper, and his own mental-health problems. All he had to do was qualify for low-income housing. And he knew just how to do that.

The paths of Mr. Black and Mr. White — one on the way down, the other seemingly on the way up — collided at the Boulevard Homeless Shelter in Harlem on Monday, through the lottery that is New York City’s shelter system.

Strangers, the men ended up in the same room of a residence for men with mental-health problems. By Wednesday night, Mr. Black was dead, his throat slashed, and Mr. White was on the run, the subject of a citywide manhunt. City officials, meanwhile, were again left with questions about how to provide shelter to everyone who needs it, even those with serious mental-health problems, even if they are not being treated or taking their medication.