The murder of four homeless men in Chinatown over the weekend is a grim ­reminder of the link ­between untreated serious mental illness and violence.

People with mild anxiety disorders aren’t violent. People who receive effective treatment for psychosis aren’t violent. But Rodriguez “Randy” Santos is one who fell through the cracks of the system. He had been arrested more than a dozen times, including for assault, and reached a point of deterioration impossible to ignore by those who knew him. Men like Santos pose a serious threat to the community.

Many see in the Chinatown murders proof that Mayor Bill de Blasio’s ThriveNYC program has failed. It’s a sensible conclusion. But an unserious program shouldn’t be tasked with serious problems. What is going to happen to more than 1,000 seriously mentally ill individuals in the jail system in the wake of the Close Rikers decarceration initiative?

Thrive has virtually no role in planning for this development, which ranks among the most important mental health challenges facing the city. Whatever the future may bring for Thrive itself, we probably need to be looking outside that program for real solutions.

Santos’ story is instructive. To his neighbors, family members and fellow homeless people, he showed many signs of his dangerousness and the severity of his illness. Dangerous people need government supervision.

For the mentally ill, government can provide both inpatient and outpatient forms of supervision, coupled with treatment.

Perhaps Santos could have benefited from outpatient supervision, via New York’s Kendra’s Law, which allows judges to order those who need it to undergo psychiatric treatment. The mentally ill have high rates of homelessness and incarceration. Many studies have documented Kendra’s Law’s success at reducing homelessness and incarceration among participants.

But Kendra’s Law is for people that we expect can live safely in the community with appropriate supports. Santos probably needed long-term hospitalization.

New York, like many jurisdictions, has been cutting back on the use of inpatient care going back many decades. Some have the impression that “deinstitutionalization” was something that happened in the 1970s or ’80s. This is incorrect. Deinstitutionalization continues to this day, 30 years after its flaws ­became evident.

This has partly to do with the high cost of hospitalization. But it is also because legal advocates don’t trust authorities’ ability to assess who is truly dangerous and in need of involuntary treatment. No regulation on civil commitment is ever stringent enough for the advocacy community.

We can’t keep cutting psychiatric beds if we want to craft an ­effective policy response to ­untreated serious mental illness and help the homeless. Untreated serious mental illness poses a serious threat to the non-mentally ill homeless.

Advocates insist that a homeless person is far more likely to be a victim of serious crime than a perpetrator. True. But they ­eschew the fact that when a homeless person is the victim of a crime, the perpetrator is usually another homeless person. That was the case with the Chinatown murders.

Crimes that happen in single-adult shelters are perpetrated by the homeless almost by definition. Whenever a street homeless person cites “unsafe conditions” as a reason for declining shelter, he is in effect saying that he is afraid of being robbed, assaulted or worse by another homeless person.

Expanding the use of commitment on an inpatient or outpatient basis would require targeting places where the untreated are likely to be found. The shelter system is one such place. The city estimates that there are about 10,700 “severely mentally ill” in the shelter system. There are more seriously mentally ill in shelters than in mental hospitals and jails combined.

We need to do more “in-reach” into shelters, specifically those for single adults suffering from mental illness, to identify candidates for outpatient and inpatient commitment. That would help reduce the risk of violence to the homeless and also improve the shelter system’s reputation among the street homeless.

At present, government institutions are under assault on both the left and the right. But whether it’s a question of outpatient or ­inpatient commitment, we need to trust government more. Some mentally ill people are simply eccentric and can handle unsupervised life in the community. But others are dangerous and at risk of profound deterioration without treatment. We need to place more trust in government’s ability to parse these two cases.

Civil commitment is a life-saving intervention. A reflexive skepticism toward state authority is no nobler than an uninformed faith in government. Our failures on mental health show why.

Stephen Eide is a Manhattan ­Institute senior fellow.