 class="p">(</span><span class="n">nodes</span><span class="p">)</span>
        <span class="n">M</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="n">n</span><span class="p">,</span><span class="n">n</span><span class="p">))</span>

        <span class="c1"># Compute the LCA matrix</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">node_i</span> <span clas