I am interested in the formula of modularity difference between two partitions considered in the Louvain algorithm for community detection in graphs. I give a formal expression of this question below.
Consider an undirected graph $G$ with vertex set $V$. If $G$ is weighted, $\omega(u,v)$ denotes the weight of the edge between $u$ and $v$ if it exists, otherwise it is $0$. If $G$ is unweighted, then it is seen as a weighted graph with each edge weight equal to $1$.
Let us denote by $m$ the half of $2m = \sum_{u\in V}\sum_{v\in V} \omega(u,v)$; it is the number of edges in $G$ if it is unweighted.
A partition $P$ of $V$ is a set of $k$ sets $P = \{C_1, C_2, \dots, C_k\}$ with $\cup_i C_i = V$ and $C_i \cap C_j = \emptyset$ if $i\neq j$.
The modularity of partition $P$ is: $$ Q(P) = \sum_{C\in P} Q(C) = \sum_{C\in P} \frac{e_C}{2m} - \left(\frac{a_C}{2m}\right)^2 $$ where $ e_C = \sum_{u\in C}\sum_{v\in C} \omega(u,v) $ and $a_C = \sum_{u\in C}\sum_{v\in V} \omega(u,v)$.
Modularity is widely used in the context of community detection in graphs, where one seeks partitions with high modularity. Then, $C_1$, $C_2$, $\dots$, $C_k$ are called communities.
The Louvain algorithm is one of the main community detection methods. It relies on the fact that one may easily compute the modularity difference between two partitions if one of them is obtained from the other by moving only one vertex from a community to another one.
Partial expressions of this modularity difference are available in the literature, including the original Louvain paper (with a typo) and in the wikipedia page on Louvain method, but I cannot find a full expression and its derivation in any published paper. All I could find is a Quora discussion on the topic, that I find quite obscure, sorry.
Finding this expression is not very challenging, but not completely trivial either, it seems, since there are many incomplete and/or flawed versions online. Given its great importance in network science, I guess I missed something.
Question: where may I find a full, clear and correct derivation of the modularity difference between two such partitions?
There are many implementations of Louvain method, and their source code certainly contains the correct formula; but it is quite technical to get it from code, and I am interested in the detailed derivation too.