CommunityStructureAssignment[g]
gives the assignment of vertices of a graph g into communities.
CommunityStructureAssignment
CommunityStructureAssignment[g]
gives the assignment of vertices of a graph g into communities.
Details and Options
- CommunityStructureAssignment functionality is now available in the built-in Wolfram Language function FindGraphCommunities.
- To use CommunityStructureAssignment, you first need to load the Graph Utilities Package using Needs["GraphUtilities`"].
- The assignment groups the vertices into communities, such that there is a higher density of edges within communities than between them.
- The following option can be given:
-
Weighted False whether edges with higher weights are preferred during matching
Examples
open all close allBasic Examples (2)
Needs["GraphUtilities`"]g = {3 -> 2, 2 -> 1, 1 -> 3, 3 -> 5, 5 -> 6, 6 -> 7, 7 -> 5};
GraphPlot[g, VertexLabeling -> True]This finds that the network is grouped into two communities:
CommunityStructureAssignment[g]CommunityStructureAssignment has been superseded by FindGraphCommunities:
g = Graph[{3 -> 2, 2 -> 1, 1 -> 3, 3 -> 5, 5 -> 6, 6 -> 7, 7 -> 5}]FindGraphCommunities[g]Map[Position[%, #, {2}, 1][[1, 1]]&, VertexList[g]]Options (1)
Weighted (1)
This specifies a weighted graph:
Needs["GraphUtilities`"]g = SparseArray[{{1, 2} -> 10, {2, 1} -> 10, {2, 3} -> 1, {3, 2} -> 1, {3, 1} -> 1, {1, 3} -> 1, {3, 5} -> 10, {5, 3} -> 10, {5, 6} -> 1, {6, 5} -> 1, {6, 4} -> 10, {4, 6} -> 10, {5, 4} -> 1, {4, 5} -> 1}, {6, 6}]This plots the graph with edge weights shown:
GraphPlot[g, VertexLabeling -> True, EdgeRenderingFunction -> ({Line[#1], Text[g[[First[#4], Last[#4]]], LineScaledCoordinate[#1], Background -> White]}&)]This finds the community structure, ignoring edge weights:
cs = CommunityStructureAssignment[g]This plots the graph, coloring the vertices based on community assignment:
GraphPlot[g, EdgeRenderingFunction -> ({Line[#1], Text[g[[First[#4], Last[#4]]], LineScaledCoordinate[#1], Background -> White]}&),
VertexRenderingFunction -> ({Text[Framed[#2, Background -> Hue[cs[[#3]] / 4], FrameStyle -> RGBColor[0.94, 0.85, 0.36]], #1]}&)]This finds the community structure, taking into account the edge weights:
cs = CommunityStructureAssignment[g, Weighted -> True]This plots the graph, coloring the vertices based on community assignment:
GraphPlot[g, EdgeRenderingFunction -> ({Line[#1], Text[g[[First[#4], Last[#4]]], LineScaledCoordinate[#1], Background -> White]}&),
VertexRenderingFunction -> ({Text[Framed[#2, Background -> Hue[cs[[#3]] / 4], FrameStyle -> RGBColor[0.94, 0.85, 0.36]], #1]}&)]Tech Notes
Related Guides
-
▪
- Graph Utilities Package ▪
- Graphs & Networks ▪
- Graph Visualization ▪
- Computation on Graphs ▪
- Graph Construction & Representation ▪
- Graphs and Matrices ▪
- Graph Properties & Measurements ▪
- Graph Operations and Modifications ▪
- Statistical Analysis ▪
- Social Network Analysis ▪
- Graph Properties ▪
- Mathematical Data Formats ▪
- Discrete Mathematics
Text
Wolfram Research (2007), CommunityStructureAssignment, Wolfram Language function, https://reference.wolfram.com/language/GraphUtilities/ref/CommunityStructureAssignment.html.
CMS
Wolfram Language. 2007. "CommunityStructureAssignment." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/GraphUtilities/ref/CommunityStructureAssignment.html.
APA
Wolfram Language. (2007). CommunityStructureAssignment. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/GraphUtilities/ref/CommunityStructureAssignment.html
BibTeX
@misc{reference.wolfram_2026_communitystructureassignment, author="Wolfram Research", title="{CommunityStructureAssignment}", year="2007", howpublished="\url{https://reference.wolfram.com/language/GraphUtilities/ref/CommunityStructureAssignment.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_communitystructureassignment, organization={Wolfram Research}, title={CommunityStructureAssignment}, year={2007}, url={https://reference.wolfram.com/language/GraphUtilities/ref/CommunityStructureAssignment.html}, note=[Accessed: 13-June-2026]}