AI Glossary / Graphs and symbolic AI / Intermediate

Modularity-based communities

Definition

Modularity-based communities are groups of graph nodes identified by seeking a partition with a high modularity score. Modularity compares the amount of connection inside groups with a degree-based reference model. The aim is to find groups whose internal connectivity is stronger than that comparison would suggest, rather than merely grouping nodes that have many edges.

What it means

A network can represent products linked by purchases, documents linked by citations, or services linked by communication. A community partition assigns each node to one group. Modularity provides one mathematical way to judge such a partition, taking account of the overall graph and the degrees of its nodes.
The result is a structural grouping under a chosen objective. It is not proof that every group corresponds to a real department, customer segment, or shared cause. Several partitions can have similar scores, and an analyst may need domain evidence to decide which interpretation is useful.

How it works

For a simple undirected graph with m edges, let L_c count edges inside community c and k_c sum the degrees of its nodes. Generalized modularity is the sum across communities of L_c/m minus gamma times (k_c/(2m)) squared. Gamma is a resolution parameter; a common setting is one.
NetworkX's greedy method begins with separate singleton communities and repeatedly merges the pair giving the greatest modularity gain, normally stopping when improvement ends. This is a heuristic search, not a guarantee of the globally best partition. Different stopping settings can end merging early or force additional merges, so they must be recorded with the result.

Three practical examples

  • A research analyst can explore groups of papers in a citation-derived network, then inspect whether the groups correspond to meaningful topics.
  • A retailer can examine product groups in a purchase-association graph to suggest merchandising questions for further analysis.
  • A software architect can identify tightly connected service groups as candidates for dependency review, while checking whether communication volume reflects good design or a bottleneck.

Think of it this way

Think of dividing a room of conversational relationships into groups and asking whether each group contains more conversation than expected from how talkative its members are. The analogy is limited because a graph needs a precise definition of an edge and its weight, and a mathematical partition may separate overlapping social roles that cannot be cleanly divided.

Worked example

Construct an invented graph with two triangles, A-B-C-A and D-E-F-D, connected by one edge C-D. There are seven edges in total. Consider the partition {A,B,C} and {D,E,F}, using gamma = 1.
Each group has three internal edges. The first group's degrees are 2, 2, and 3, summing to 7; the second has the same degree sum. Each contribution is 3/7 - (7/14)^2 = 3/7 - 1/4 = 5/28. Total modularity is 10/28 = 5/14, approximately 0.357.
If all six nodes form one community, its score is 7/7 - (14/14)^2 = 0. The two-triangle partition therefore scores better than the single-group partition under these assumptions. This comparison does not by itself prove global optimality or claim that a particular implementation was run.
With gamma = 2, the same two-group partition scores 2(3/7 - 2/4) = -1/7. Changing the resolution changes the objective, so scores from different settings are not a direct performance ranking.

Illustrative case study

In a fictional subscription business, an analyst builds a graph linking articles that readers frequently visit together. A modularity method produces several groups. Editors find that some resemble topics, while another combines unrelated articles promoted together on the homepage.
The team checks how edge definitions, promotion periods, and resolution settings affect the grouping. It uses stable, interpretable findings to guide an editorial review, rather than treating every group as a newly discovered audience type. The scenario illustrates investigation of a graph partition; it does not report an actual company experiment or improvement in engagement.

Common misconceptions and mistakes

High modularity is not a universal certificate of meaningful structure. The graph may encode missing data, popularity effects, or collection artifacts. Maximizing the score can also merge small but meaningful groups, a known reason to inspect resolution and alternative methods.
Do not assume the greedy procedure searches every partition or returns the unique answer. Also distinguish communities from connected components: the worked graph is connected but has a useful two-group candidate. Finally, a partition assigns each node once. If the application requires overlapping memberships, that requirement is not captured by an ordinary disjoint modularity partition.

Business use

The practical value is often to create a manageable set of hypotheses about relationships in a large network. Before acting, explain what nodes and edges mean, why the weighting is appropriate, and which question the grouping supports. A group of frequently interacting services might indicate a useful module or an unwanted dependency; the graph score cannot decide that interpretation alone.
Keep the graph snapshot, parameters, and partition together. Test sensitivity to reasonable changes and compare with known operational categories where available. When using software, align weighting choices between the detection method and the scoring method so the reported score evaluates the same graph interpretation.

People also ask

Does larger modularity always mean a better business grouping?

No. It means a better score under a particular graph, reference model, and resolution, which may not match the business objective.

Must communities be disconnected?

No. Communities commonly retain edges between them.

Does increasing resolution always reveal the true groups?

No. Higher resolution generally favors smaller groups, but selecting it remains a modeling choice that needs interpretation and validation.

Check your understanding

How many edges cross between the two groups in the worked example?

Answer: One, C-D. It contributes to the degrees of C and D but is not counted among either group's internal edges. Omitting it from the degree sums would produce an incorrect modularity calculation.

Related terms

  • Greedy algorithms
  • Weighted graph
  • Local Community Detection
  • modularity
  • community detection
  • graph partition
  • greedy algorithm
  • resolution parameter
  • degree
  • connected component
  • Louvain method

Learn next

Remove the bridging edge and recompute the two-group score at gamma = 1. With six total edges and degree sum six in each group, each contribution becomes 3/6 - (6/12)^2 = 1/4, giving total modularity 1/2. Explain which terms changed and why.

More in Graphs and symbolic AI

  • Modal logic - Modal logic is a family of formal systems that extends ordinary logical statements with ways to express qualifications such as necessity, possibility...
  • Modal operators - Modal operators are logical symbols that qualify a statement with a meaning such as “necessarily,” “possibly,” “knows,” or “believes.
  • Model-based reasoning - Model-based reasoning draws conclusions by using an explicit representation of how a system is structured or behaves.
  • Modus ponens - Modus ponens is a rule of logical inference: from “if P, then Q” and “P,” infer “Q. It is a truth-preserving pattern of deduction in classical logic.
  • Monoidal t-norm logic - Monoidal t-norm logic, usually abbreviated MTL, is a formal system of mathematical fuzzy logic associated with all left-continuous triangular norms and...
  • Monotonic preference - A monotonic preference is a preference that moves consistently in a specified direction as an attribute increases, with other relevant conditions held fixed.

Sources

Sources: NetworkX, greedy_modularity_communities: https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.community.modularity_max.greedy_modularity_communities.html . NetworkX, modularity definition: https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.community.quality.modularity.html . Fortunato and Barthelemy, Resolution limit in community detection, original research abstract: https://arxiv.org/abs/physics/0607100 . All graph calculations and the editorial case are original illustrations.

Previous: Modular Language Model Next: Modulo-N code

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer