Directed Modularity Analysis

Machine Learning
Introduced by
Leicht, E. A. & Newman, M. E. J.
Year
2008
Type
Community detection / graph partitioning
Family
Network science

What does it do?

Directed modularity analysis extends the Newman-Girvan modularity framework to directed graphs, where each edge has a source and a destination.

Leicht and Newman formalized it in 2008. It partitions nodes into communities by maximizing a modularity score whose null model uses each node's out-degree and in-degree separately. This makes it an approach to community detection in directed networks, such as citation networks, information flows, and other asymmetric relational data.

The intuition behind the method

In an undirected network, a community is a set of nodes that link to each other more than chance would predict. In a directed network the same logic needs a different baseline, because a node's tendency to send edges (out-degree) and its tendency to receive them (in-degree) are different quantities. Directed modularity builds both into the null model, so the expected number of edges from i to j depends on i's sending activity and j's receiving activity. The algorithm then favours groups in which edges run more densely than this expectation, that is, sets of nodes with more within-group directed edges than the null model predicts.

History

Newman and Girvan introduced modularity as a quality function for community detection in undirected networks in 2004. Leicht and Newman's 2008 Physical Review Letters paper argued that earlier work often ignored edge direction and generalized modularity maximization to incorporate direction in a principled way. They described an explicit spectral algorithm for the directed case and compared it with earlier methods on test networks.

When to use it

Use directed modularity analysis when your edges are asymmetric, such as citations, follows, information flows, trade links, or hyperlinks, and you want communities that respect edge direction. It is the directed generalization of modularity and is appropriate when undirected modularity would discard meaningful asymmetry. Do not use it when the ties are genuinely undirected, such as co-authorship or co-occurrence, where standard undirected modularity is simpler and easier to interpret. Also be cautious with very sparse or nearly acyclic networks, such as strict temporal DAGs, where the directed null model may be a poor baseline. Very small networks rarely give stable partitions, so check stability before interpreting them.

Limitations and considerations

  • Modularity maximization is NP-hard, so all practical algorithms are heuristics, and different runs can return different partitions.
  • Modularity has a resolution limit: small communities can be merged into larger ones, depending on the size of the network.
  • The value of Q does not by itself determine the correct number of communities; the partition needs separate validation.
  • P_ij gives expected edge counts, not exact degrees, and the null model can be a poor baseline in very sparse directed networks.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • The null model P_ij pairs the out-degree of the source with the in-degree of the target, so an edge is judged against each node's sending and receiving activity rather than a symmetrized total.
  • Q is a single score measured against a defined null model, so it can be compared across candidate partitions of the same network.
  • The original paper reports, on a variety of real and computer-generated test networks, better results than earlier approaches that ignored edge direction.
  • The objective can be optimized with heuristics such as Louvain or Leiden, which are far cheaper than exhaustive search.

Applications

  • Citation network analysis: identifying research communities and knowledge domains from asymmetric citation links.
  • Social media: detecting follower/followee communities in Twitter or Instagram graphs.
  • Biological networks: finding functional modules in gene regulatory or metabolic networks with directed interactions.
  • Web graph clustering: grouping hyperlink-connected pages into topical communities.
  • Trade and economic networks: partitioning countries into trade blocs based on directed import/export flows.
  • Information diffusion: mapping communities through which rumors or innovations spread directionally.

How it works

How it works

1

Represent the network as a directed graph with an n x n asymmetric adjacency matrix A, where A_ij = 1 (or the edge weight) indicates an edge from node i to node j. Record each node's out-degree (edges sent) and in-degree (edges received), since both enter the null model.

2

Compute the expected number of edges from i to j under a random model with the same out-degree and in-degree sequences: P_ij = k_i^out * k_j^in / m, where m is the total number of edges. This is an expectation, not an exact constraint on each node's degrees. It accounts for nodes that send many edges and nodes that receive many edges.

Formula
P_{ij} = \frac{k_i^{\text{out}} k_j^{\text{in}}}{m}
3

Compute the directed modularity Q for a given partition as the sum over all node pairs of (A_ij - P_ij), counting only pairs assigned to the same community (the delta indicator), and divide by m. Q near zero means the within-community edges are about as frequent as the null model predicts; positive Q means they are more frequent. Q is the objective that the optimization step searches to maximize.

Formula
Q = \frac{1}{m} \sum_{ij} \!\left(A_{ij} - P_{ij}\right) \delta(c_i, c_j)
4

Search for the partition that maximizes Q. Exact maximization is NP-hard, so practical methods are heuristics. One option is a spectral optimization of the directed modularity, as described in Leicht and Newman (2008). Another is a greedy or multilevel procedure from the Louvain or Leiden family, which iteratively moves nodes between communities when this increases Q. Whether a particular Louvain- or Leiden-type implementation optimizes the directed objective with the null model defined above depends on the software. Check its documentation for directed-edge support, and recompute Q from the formula to confirm the reported value. Different runs can return different partitions.

5

Assess the result using the final Q value, its stability across repeated runs (because the heuristics are non-deterministic), and whether the communities are interpretable in the domain. To judge whether Q is high relative to chance, build a randomized baseline: generate directed networks that keep each node's in-degree and out-degree, for example by repeated directed edge swaps that preserve both sequences while avoiding self-loops and duplicate edges; run the same optimizer on each randomized network; and compare the observed Q with the distribution of Q values obtained from the randomized networks. Run the optimizer on the original network several times, increasing the number of runs until the Q values and partitions stop changing meaningfully for your purpose; the number needed depends on the network and the optimizer. Finally, inspect the reordered adjacency matrix to check whether within-community edge density exceeds the null-model expectation.

Common pitfalls

  • Applying undirected modularity to a directed network discards the direction information that defines the community structure.
  • Running the optimizer once and treating the result as definitive, without checking whether the partition is stable across runs.
  • Ignoring the resolution limit and concluding that a single large community means no finer structure exists.
  • Reading a high Q as proof of meaningful communities without comparing it to Q from randomized or alternative partitions of the same network, and without checking whether the groups are interpretable.
  • Applying directed modularity to a nearly complete graph, where almost every partition yields similar Q values and the score carries little information.

Frequently asked questions

Why can I not just symmetrize my directed network and run standard modularity?

Symmetrizing treats each directed edge as undirected and so loses the distinction between nodes that mainly send edges and nodes that mainly receive them. In citation networks, a highly cited paper and a prolific citing paper play different structural roles. Directed modularity keeps this distinction through the separate out-degree and in-degree terms in the null model, while undirected modularity combines them.

What Q value indicates a good partition?

There is no universal threshold. Q depends on network size and density, so judge a partition by comparing its Q with a randomized baseline of the same network and by checking whether the communities are stable and interpretable, rather than relying on an absolute cutoff.

Which algorithm should I use to maximize directed modularity?

Louvain- and Leiden-type heuristics are common choices for moderate to large networks because they are fast. Confirm that the implementation you use accepts directed edges and optimizes the Leicht-Newman objective, since a tool may symmetrize edges internally, in which case its output is not directed modularity. Spectral optimization of the directed modularity, as described in Leicht and Newman (2008), is another option. Because all practical methods are heuristics, run the chosen method several times, check that the partitions agree, and recompute Q from the formula to confirm the reported value.

How do I choose the number of communities?

Directed modularity optimization determines the number of communities implicitly as part of maximizing Q. Some Louvain- and Leiden-type implementations expose an optional resolution parameter (gamma) that changes the granularity of the partition. Using it means optimizing a modified objective rather than the Q defined on this page, so Q values obtained with different gamma settings, or compared with unmodified Q values, are not directly comparable. Validate the chosen granularity by inspecting the members of each community and by checking whether the partition remains stable across repeated runs.

Can directed modularity handle weighted edges?

Yes. Replace the binary adjacency matrix A with a weighted matrix W, and define k_i^out and k_j^in as the total out-strength and in-strength of the nodes. The formula for Q and the null model P_ij adapt in the same way.

Related methods

Sources

  1. Leicht, E. A., & Newman, M. E. J. (2008). Community structure in directed networks. Physical Review Letters, 100(11), 118703.

    Open DOI reference
  2. Newman, M. E. J., & Girvan, M. (2004). Finding and evaluating community structure in networks. Physical Review E, 69(2), 026113.

    Open DOI reference