">k</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
        <span class="n">distances</span> <span class="o">=</span> <span class="n">distance_matrix</span><span class="p">[</span><span class="n">triu_indices</span><span class="p">]</span>
        <span class="n">i_min_dist</span> <span class="o">=</span> <span class="n">distances</span><span class="o">.</span><span class="n">min</span><span class="p">()</span>

        <span class="k">if</span> <span class="n">min_distance</