CommunityModularity
CommunityModularity[g,partition]
gives the community modularity of a partition.
CommunityModularity[g,assignment]
gives the community modularity of an assignment.
Details and Options
- CommunityModularity functionality is now available in the built-in Wolfram Language function GraphAssortativity.
- To use CommunityModularity, you first need to load the Graph Utilities Package using Needs["GraphUtilities`"].
- A community in a network is a group of vertices such that there is a higher density of edges within the group than between them.
- Given a graph
, let the vertex set
be partitioned into
subsets
such that each subset belongs to one community. The community modularity
of this partition is defined as
, where
is the percentage of edges that have both ends in community
, and
is the percentage of edges that start from community
. In other words,
and
.
- The community modularity
is a number less than or equal to 1. A large positive value indicates that the vertex partition gives significant community structure.
- The following option can be given:
-
Weighted False whether edges with higher weights are preferred during matching
Examples
open allclose allBasic Examples (2)Summary of the most common use cases

https://wolfram.com/xid/0v07q4w9a6tk87he-jcfcec

https://wolfram.com/xid/0v07q4w9a6tk87he-6gkdid

https://wolfram.com/xid/0v07q4w9a6tk87he-bjd3n5

This gives the community modularity, assuming a partition {{1,2,3},{4,5,6}}:

https://wolfram.com/xid/0v07q4w9a6tk87he-k8rzul

CommunityModularity has been superseded by GraphAssortativity:

https://wolfram.com/xid/0v07q4w9a6tk87he-qs9cop


https://wolfram.com/xid/0v07q4w9a6tk87he-zzf40

Options (1)Common values & functionality for each option
Weighted (1)
This defines a graph with edge weights:

https://wolfram.com/xid/0v07q4w9a6tk87he-8vmc22

https://wolfram.com/xid/0v07q4w9a6tk87he-7mkkh0

https://wolfram.com/xid/0v07q4w9a6tk87he-nskqab

The community modularity of partition {{1,2},{3,4}}, ignoring edge weights:

https://wolfram.com/xid/0v07q4w9a6tk87he-r2ckeb

The community modularity of partition {{1,2},{3,4}}, taking into account edge weights:

https://wolfram.com/xid/0v07q4w9a6tk87he-vtk5tg

When taking into account edge weights, partition {{1,4},{2,3}} has higher community modularity:

https://wolfram.com/xid/0v07q4w9a6tk87he-8szl9n

Wolfram Research (2007), CommunityModularity, Wolfram Language function, https://reference.wolfram.com/language/GraphUtilities/ref/CommunityModularity.html.
Text
Wolfram Research (2007), CommunityModularity, Wolfram Language function, https://reference.wolfram.com/language/GraphUtilities/ref/CommunityModularity.html.
Wolfram Research (2007), CommunityModularity, Wolfram Language function, https://reference.wolfram.com/language/GraphUtilities/ref/CommunityModularity.html.
CMS
Wolfram Language. 2007. "CommunityModularity." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/GraphUtilities/ref/CommunityModularity.html.
Wolfram Language. 2007. "CommunityModularity." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/GraphUtilities/ref/CommunityModularity.html.
APA
Wolfram Language. (2007). CommunityModularity. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/GraphUtilities/ref/CommunityModularity.html
Wolfram Language. (2007). CommunityModularity. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/GraphUtilities/ref/CommunityModularity.html
BibTeX
@misc{reference.wolfram_2025_communitymodularity, author="Wolfram Research", title="{CommunityModularity}", year="2007", howpublished="\url{https://reference.wolfram.com/language/GraphUtilities/ref/CommunityModularity.html}", note=[Accessed: 08-July-2025
]}
BibLaTeX
@online{reference.wolfram_2025_communitymodularity, organization={Wolfram Research}, title={CommunityModularity}, year={2007}, url={https://reference.wolfram.com/language/GraphUtilities/ref/CommunityModularity.html}, note=[Accessed: 08-July-2025
]}