class_docstr: Community walking strategy which groups vertices with similar properties
  through probabilities and relations that are not explicitly modeled in a
  Knowledge Graph. Similar to the Random walking strategy, the Depth First
  Search (DFS) algorithm is used if a maximum number of walks is specified.
  Otherwise, the Breadth First Search (BFS) algorithm is chosen.
  
  Attributes:
      _is_support_remote: True if the walking strategy can be used with a
          remote Knowledge Graph, False Otherwise.
          Defaults to True.
      hop_prob: The probability to hop.
          Defaults to 0.1.
      kg: The global KG used later on for the worker process.
          Defaults to None.
      max_depth: The maximum depth of one walk.
      max_walks: The maximum number of walks per entity.
          Defaults to None.
      md5_bytes: The number of bytes to keep after hashing objects in
          MD5. Hasher allows to reduce the memory occupied by a long
          text. If md5_bytes is None, no hash is applied.
          Defaults to 8.
      random_state: The random state to use to keep random determinism with
          the walking strategy.
          Defaults to None.
      resolution: The resolution to use.
          Defaults to The resolution to use.
      sampler: The sampling strategy.
          Defaults to UniformSampler.
      with_reverse: True to extracts parents and children hops from an
          entity, creating (max_walks * max_walks) walks of 2 * depth,
          allowing also to centralize this entity in the walks. False
          otherwise.
          Defaults to False.
docstr: Converts the knowledge graph to a networkX graph.
  
  Note:
      You can create a `graph.KnowledgeGraph` object from an
      `rdflib.Graph` object by using a converter method.
  
  Args:
      kg: The Knowledge Graph.
docstr_tok: ["Converts","the","knowledge","graph","to","a","networkX","graph",".","Note",":","You","can","create","a","`","graph.KnowledgeGraph","`","object","from","an","`","rdflib.Graph","`","object","by","using","a","converter","method",".","Args",":","kg",":","The","Knowledge","Graph","."]
code: def _community_detection(self, kg: KG) -> None:
      """Converts the knowledge graph to a networkX graph.
  
      Note:
          You can create a `graph.KnowledgeGraph` object from an
          `rdflib.Graph` object by using a converter method.
  
      Args:
          kg: The Knowledge Graph.
  
      """
      nx_graph = nx.Graph()
  
      for vertex in kg._vertices:
          if not vertex.predicate:
              nx_graph.add_node(str(vertex), vertex=vertex)
  
      for vertex in kg._vertices:
          if not vertex.predicate:
              # Neighbors are predicates
              for pred in kg.get_neighbors(vertex):
                  for obj in kg.get_neighbors(pred):
                      nx_graph.add_edge(
                          str(vertex), str(obj), name=str(pred)
                      )
  
      # Create a dictionary that maps the URI on a community
      partition = community.best_partition(
          nx_graph, resolution=self.resolution
      )
      self.labels_per_community = defaultdict(list)
  
      self.communities = {}
      vertices = nx.get_node_attributes(nx_graph, "vertex")
      for node in partition:
          if node in vertices:
              self.communities[vertices[node]] = partition[node]
  
      for node in self.communities:
          self.labels_per_community[self.communities[node]].append(node)
  
imports: import itertools
  import math
  from collections import defaultdict
  from hashlib import md5
  from typing import List, Optional, Set
  import attr
  import community
  import networkx
  import numpy
  from pyrdf2vec.graphs import KG, Vertex
  from pyrdf2vec.typings import Entities, EntityWalks, SWalk, Walk
  from pyrdf2vec.walkers import Walker
label_desc: Use image node_id 1 for calling the CommunityWalker obj's underlying member method code with example usage: obj._community_detection(kg) without return types