class_docstr: Weisfeiler-Lehman feature extractor class.
  
  Args:
      graph (NetworkX graph): NetworkX graph for which we do WL hashing.
      wl_iterations (int): Number of WL iterations.
      use_node_attribute (Optional[str]): Optional attribute name to be used.
      erase_base_feature (bool): Deleting the base features.
class_docstr_tok: ["Weisfeiler-Lehman","feature","extractor","class",".","Args",":","graph","(","NetworkX","graph",")",":","NetworkX","graph","for","which","we","do","WL","hashing",".","wl_iterations","(","int",")",":","Number","of","WL","iterations",".","use_node_attribute","(","Optional","[","str","]",")",":","Optional","attribute","name","to","be","used",".","erase_base_feature","(","bool",")",":","Deleting","the","base","features","."]
docstr: Creating the features.
docstr_tok: ["Creating","the","features","."]
code: def _set_features(self):
      """
      Creating the features.
      """
      if self.use_node_attribute is not None:
          # We retrieve the features of the nodes with the attribute name
          # `feature` and assign them into a dictionary with structure:
          # {node_a_name: feature_of_node_a}
          # Nodes without this feature will not appear in the dictionary.
          features = nx.get_node_attributes(
              self.graph, self.use_node_attribute
          )
  
          # We check whether all nodes have the requested feature
          if len(features) != self.graph.number_of_nodes():
              missing_nodes = []
              # We find up to five missing nodes so to make
              # a more informative error message.
              for node in tqdm(
                  self.graph.nodes,
                  total=self.graph.number_of_nodes(),
                  leave=False,
                  dynamic_ncols=True,
                  desc="Searching for missing nodes",
              ):
                  if node not in features:
                      missing_nodes.append(node)
                  if len(missing_nodes) > 5:
                      break
              raise ValueError(
                  (
                      "We expected for ALL graph nodes to have a node "
                      "attribute name `{}` to be used as part of "
                      "the requested embedding algorithm, but only {} "
                      "out of {} nodes has the correct attribute. "
                      "Consider checking for typos and missing values, "
                      "and use some imputation technique as necessary. "
                      "Some of the nodes without the requested attribute "
                      "are: {}"
                  ).format(
                      self.use_node_attribute,
                      len(features),
                      self.graph.number_of_nodes(),
                      missing_nodes,
                  )
              )
          # If so, we assign the feature set.
          self.features = features
      else:
          self.features = {
              node: self.graph.degree(node)
              for node in self.graph.nodes()
          }
      self.extracted_features = {
          k: [str(v)] for k, v in self.features.items()
      }
  
file_path: karateclub/karateclub/utils/treefeatures.py
imports: import hashlib
  import networkx
  from tqdm.auto import tqdm
  from typing import List, Dict, Optional
label_desc: Use image node_id 2 for calling the WeisfeilerLehmanHashing obj's underlying member method code with example usage: obj._set_features() without return types