The OPTGRAPH Procedure

Example 1.8 Recursive Community Detection on Zachary’s Karate Club Data

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

node community_1
0 3
9 2
10 6
14 7
15 3
16 3
19 3
20 4
21 3
23 3
24 9
27 1
28 9
29 8
30 1
31 2
32 8
33 3
2 4
1 5
3 6
4 7
5 0
6 0
7 0
8 6
11 0
12 5
13 7
17 0
18 5
22 4
26 9
25 9



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

level resolution community nodes
1 1 0 5
1 1 1 2
1 1 2 2
1 1 3 7
1 1 4 3
1 1 5 3
1 1 6 3
1 1 7 3
1 1 8 2
1 1 9 4



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

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.