Skip to main content
. 2023 Sep 10;25(9):1320. doi: 10.3390/e25091320
Algorithm 2 Node enthusiasm measurement based on the GN algorithm
Input: G
Output: Q, communitymax
 1:    while len(G.edges()) > 0 do  //Determine whether any node in the graph is a community
 2:          edge = max(edge_betweenness(G))    //Find the edge with the largest edge betweenness in the graph
 3:          G.remove_edge(edge[0], edge[1])      //Remove the edges with the largest edge betweenness
 4:          components = connected_components(G)    //The connected subgraph is obtained after removing the edges
 5:          if len(components)! = len(nodes):      //Determine whether any node of the connected subgraph is a community
 6:                 Q, community = cal_Q(components, G) //Calculate the modularity metric value Q
 7:                 if Qn > Qmax: //Determine whether the sum Qn of Q values is maximum
 8:                           Q, Qmax, communitymax = Q, Qn, community //Record the communities that are now formed, Q and Qn
 9:                 end if
 10:          end if
 11:    end while
 12: return Q, communitymax