class_docstr: An implementation of `"SCD" <http://wwwconference.org/proceedings/www2014/proceedings/p225.pdf>`_ from the
  WWW '14 paper "High Quality, Scalable and Parallel Community Detection for
  Large Real Graphs". The procedure greedily optimizes the approximate weighted
  community clustering metric. First, clusters are built around highly clustered nodes.
  Second, we refine the initial partition by using the approximate WCC. These refinements
  happen for the whole vertex set.
  
  Args:
      iterations (int): Refinemeent iterations. Default is 25.
      eps (float): Epsilon score for zero division correction. Default is 10**-6.
      seed (int): Random seed value. Default is 42.
class_docstr_tok: ["An","implementation","of","`","``","SCD","''","<","http",":","\/\/wwwconference.org\/proceedings\/www2014\/proceedings\/p225.pdf",">","`","_","from","the","WWW","'14","paper","``","High","Quality",",","Scalable","and","Parallel","Community","Detection","for","Large","Real","Graphs","''",".","The","procedure","greedily","optimizes","the","approximate","weighted","community","clustering","metric",".","First",",","clusters","are","built","around","highly","clustered","nodes",".","Second",",","we","refine","the","initial","partition","by","using","the","approximate","WCC",".","These","refinements","happen","for","the","whole","vertex","set",".","Args",":","iterations","(","int",")",":","Refinemeent","iterations",".","Default","is","25.","eps","(","float",")",":","Epsilon","score","for","zero","division","correction",".","Default","is","10","*","*","-6.","seed","(","int",")",":","Random","seed","value",".","Default","is","42","."]
code: def _do_refinement(self):
      new_memberships = {}
      inverse_community_index = self._create_inverse_community_index()
      community_statistics = self._calculate_community_statistics(
          inverse_community_index
      )
      community_index = self._find_community_index(community_statistics)
      for node in self._nodes:
          community_level_stats = community_statistics[
              self._cluster_memberships[node]
          ]
          neighbors = set(
              [neighbor for neighbor in self._graph.neighbors(node)]
          )
          candidate_communities = [
              self._cluster_memberships[neighbor]
              for neighbor in neighbors
          ]
          d_out = len(
              set(neighbors).difference(
                  inverse_community_index[
                      self._cluster_memberships[node]
                  ]
              )
          )
          d_in = len(neighbors) - d_out
          WCC_r = -self._calculate_wcc(
              community_level_stats, d_out, d_in
          )
          WCC_t = 0
          best_community = None
          for comm in candidate_communities:
              community_level_stats = community_statistics[comm]
              d_out = len(
                  set(neighbors).difference(
                      inverse_community_index[comm]
                  )
              )
              d_in = len(neighbors) - d_out
              WCC_aux = (
                  self._calculate_wcc(
                      community_level_stats, d_out, d_in
                  )
                  + WCC_r
              )
              if WCC_aux > WCC_t:
                  WCC_t = WCC_aux
                  best_community = comm
          if WCC_r > WCC_t and WCC_r > 0:
              new_memberships[node] = community_index
              community_index = community_index + 1
          elif WCC_t > WCC_r and WCC_t > 0:
              new_memberships[node] = best_community
          else:
              new_memberships[node] = self._cluster_memberships[node]
      self._cluster_memberships = new_memberships
  
file_path: karateclub/karateclub/community_detection/non_overlapping/scd.py
imports: import networkx
  from typing import Dict
  from karateclub.estimator import Estimator
label_desc: Use image node_id 13 for calling the SCD obj's underlying member method code with example usage: obj._do_refinement() without return types