procedural generated mesh vertices are not connected in edges

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class MeshDeformer : MonoBehaviour
{
    public MeshFilter meshFilter;
    private Mesh mesh;
    public GameObject nearest, contactPoint;
    MeshCollider meshCollider;
    

    void Start()
    {
        meshFilter = GetComponent<MeshFilter>();
        mesh = meshFilter.mesh;
        
        meshCollider = GetComponent<MeshCollider>();
        
    }

    

    void OnCollisionEnter(Collision col)
    {

        deformMesh(col);

    }
    void deformMesh(Collision collision)
    {
        bool[] isProcessed = new bool[mesh.vertexCount];
        Vector3[] tempVerticies = new Vector3[mesh.vertexCount];
        tempVerticies = mesh.vertices;
        ContactPoint[] contacts = collision.contacts;
        
        string collidingVertexes = "";
        
        foreach (ContactPoint c in contacts)
        {
            
            Vector3 lp = contactPoint.transform.InverseTransformPoint(c.point);

            
            int nearestVertexId = getNearestVertexId(lp);

            if (!isProcessed[nearestVertexId])
            {
                isProcessed[nearestVertexId] = true;

                collidingVertexes += nearestVertexId + ";";

                tempVerticies[nearestVertexId] += contactPoint.transform.InverseTransformDirection(collision.relativeVelocity.normalized)/50;

                

            }
        }
        
        Debug.Log("Colliding vertexId: "+ collidingVertexes);
        mesh.vertices = tempVerticies;
        mesh.RecalculateNormals();
        mesh.RecalculateBounds();
        meshFilter.sharedMesh = mesh;
        meshCollider.sharedMesh = null;
        meshCollider.sharedMesh = mesh;
    }

    int getNearestVertexId(Vector3 point)
    {
        
        float min = Mathf.Infinity;

        int minId = -1;

        for (int i = 0; i < mesh.vertexCount; i++)
        {
            float dist = (point - mesh.vertices*).magnitude;*

if (dist < min)
{
min = dist;
minId = i;
}

}

return minId;
}

}
[84935-mesh.png|84935]*
*
What’s wrong?

The problem was in Unity buil it sphere mesh, that has dublicate vertices.