This example illustrates the use of the RECURSIVE option in community detection on Zachary’s Karate Club data. The data set appears in Community Detection on Zachary’s Karate Club Data. This example forces each community to contain no more than five nodes and the number of links between any pair of nodes within any community to be no greater than 2.
proc optgraph data_links = LinkSetIn out_nodes = NodeSetOut graph_internal_format = thin; community resolution_list = 1.0 recursive (max_comm_size = 5 max_diameter = 2 relation = AND) out_community = CommOut; run;
The data set NodeSetOut
contains the community identifier of each node. It is shown in Output 1.8.1.
Output 1.8.1: Community Nodes Output
The data set CommOut
contains the number of nodes contained in each community. It is shown in Output 1.8.2.
Output 1.8.2: Community Number of Nodes Output
The community graph is shown in Figure 1.147, with different node shapes and colors representing different communities.
Figure 1.147: Karate Club Recursive Communities
As you can see from Output 1.8.2, Community 3, whose nodes are drawn as black ellipses in Figure 1.147, contains seven nodes even though the maximum number of nodes in any community is set to be 5. This is because Community 3 has a symmetric shape: Nodes 0 and 33 are in the center, and they symmetrically connect to Nodes 21, 15, 19, 16, and 23. Therefore, this community cannot be further split.