code: def label_propagation_communities(G):
      """Generates community sets determined by label propagation
  
      Finds communities in `G` using a semi-synchronous label propagation
      method [1]_. This method combines the advantages of both the synchronous
      and asynchronous models. Not implemented for directed graphs.
  
      Parameters
      ----------
      G : graph
          An undirected NetworkX graph.
  
      Returns
      -------
      communities : iterable
          A dict_values object that contains a set of nodes for each community.
  
      Raises
      ------
      NetworkXNotImplemented
         If the graph is directed
  
      References
      ----------
      .. [1] Cordasco, G., & Gargano, L. (2010, December). Community detection
         via semi-synchronous label propagation algorithms. In Business
         Applications of Social Network Analysis (BASNA), 2010 IEEE International
         Workshop on (pp. 1-8). IEEE.
      """
      coloring = _color_network(G)
      # Create a unique label for each node in the graph
      labeling = {v: k for k, v in enumerate(G)}
      while not _labeling_complete(labeling, G):
          # Update the labels of every node with the same color.
          for color, nodes in coloring.items():
              for n in nodes:
                  _update_label(n, labeling, G)
  
      clusters = defaultdict(set)
      for node, label in labeling.items():
          clusters[label].add(node)
      return clusters.values()
  
file_path: networkx/networkx/algorithms/community/label_propagation.py
imports: from collections import Counter, defaultdict, deque
  import networkx
  from networkx.utils import groups, not_implemented_for, py_random_state
label_desc: Use image node_id 4 for calling a global function with example usage: label_propagation_communities(G) and returns: clusters