<p>The method of modularity maximization (of which Leiden is an implementation) has two important properties:</p>
<ol>
<li>It only searches for assortative communities (i.e. groups with more internal connections than external ones).</li>
<li>It is a <strong>statistically inconsistent</strong> method, that will both overfit and underfit, depending on the situation. A discussion on this matter can be found here: <a href="https://skewed.de/tiago/blog/modularity-harmful" rel="nofollow noreferrer">https://skewed.de/tiago/blog/modularity-harmful</a></li>
</ol>
<p>The SBM inference method is different in both counts:</p>
<ol>
<li>It finds groups with arbitrary mixing patterns, i.e. preferences of connections to other groups. Assortativity is a special case, but there are many others possible patterns.</li>
<li>It achieves this in a statistically principled manner, avoiding both overfitting and underfitting. For a theoretical introduction, see: <a href="https://arxiv.org/abs/1705.10225" rel="nofollow noreferrer">https://arxiv.org/abs/1705.10225</a>. For a discussion on the differences between inferential and non-inferential methods see: <a href="https://arxiv.org/abs/2112.00183" rel="nofollow noreferrer">https://arxiv.org/abs/2112.00183</a></li>
</ol>
<p>Because of the above, one should not expect SBM inference and Leiden/Louvain to yield similar answers in general.</p>
<p>Now, for whatever reason, you may be interested to find only assortative communities. You can also do that with the SBM, but using a more constrained parametrization. You can do this with graph-tool as explained here: <a href="https://graph-tool.skewed.de/static/doc/demos/inference/inference.html#assortative-community-structure" rel="nofollow noreferrer">https://graph-tool.skewed.de/static/doc/demos/inference/inference.html#assortative-community-structure</a></p>
Graph tool - Stochastic Block Model vs Leiden
<p>I'm calculating network communities for 4 networks using 2 methods:</p>
<ol>
<li><p>'Leiden' method, which gives me 7 (a), 13 (b), 19 (c), 22 (d) communities.</p>
</li>
<li><p>'Stochastic block Model', also checking group membership of the nodes by inspecting levels of the hierarchy, like so:</p>
</li>
</ol>
<hr />
<pre><code>    state = gt.inference.minimize_nested_blockmodel_dl(g)
    state.print_summary()

    levels = state.get_levels()
    for s in levels:
        print(s)
        if s.get_N() == 1:
            break
    lstate = state.levels[0]
    b = lstate.get_blocks()
    print(b[10])
</code></pre>
<hr />
<p>which prints:</p>
<pre><code>&lt;BlockState object with 228 blocks (21 nonempty), degree-corrected, for graph &lt;Graph object, undirected, with 228 vertices and 1370 edges, 1 internal vertex property, 1 internal edge property, at 0x7fbaff1c8d50&gt;, at 0x7fba9fac1bd0&gt;
&lt;BlockState object with 21 blocks (6 nonempty), for graph &lt;Graph object, undirected, with 228 vertices and 96 edges, at 0x7fb9a3c51910&gt;, at 0x7fb9a2dd1a10&gt;
&lt;BlockState object with 6 blocks (1 nonempty), for graph &lt;Graph object, undirected, with 21 vertices and 20 edges, at 0x7fb9a3c51590&gt;, at 0x7fb9a3c51ed0&gt;
&lt;BlockState object with 1 blocks (1 nonempty), for graph &lt;Graph object, undirected, with 6 vertices and 1 edge, at 0x7fb9a6f034d0&gt;, at 0x7fb9a3c51790&gt;
190
&lt;Graph object, undirected, with 3459 vertices and 134046 edges, 1 internal vertex property, 1 internal edge property, at 0x7fbb62e22790&gt;
l: 0, N: 3459, B: 294
l: 1, N: 294, B: 85
l: 2, N: 85, B: 34
l: 3, N: 34, B: 12
l: 4, N: 12, B: 4
l: 5, N: 4, B: 1
l: 6, N: 1, B: 1
</code></pre>
<hr />
<p>and draws:</p>
<p><a href="https://i.stack.imgur.com/VoSa7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VoSa7.jpg" alt="enter image description here" /></a></p>
<p>This looks like having WAY more communities than using Leiden, and I'm trying to wrap my head around why, as well as this SBM concept.</p>
<p>Are these SBM graphs depicting adicional levels of hierarchy or is there something else going on here that justifies so many more communities?</p>