code: def get_bonded_structure(self, structure, decorate=False):
          
  
          # requires optional dependency which is why it's not a top-level import
          from pymatgen.analysis.graphs import MoleculeGraph
  
          if decorate:
              # Decorate all sites in the underlying structure
              # with site properties that provides information on the
              # coordination number and coordination pattern based
              # on the (current) structure of this graph.
              order_parameters = [self.get_local_order_parameters(structure, n)
                                  for n in range(len(structure))]
              structure.add_site_property('order_parameters', order_parameters)
  
          mg = MoleculeGraph.with_local_env_strategy(structure, self)
  
          return mg
docs: Obtain a MoleculeGraph object using this NearNeighbor
          class. Requires the optional dependency networkx
          (pip install networkx).
  
          Args:
              structure: Molecule object.
              decorate (bool): whether to annotate site properties
              with order parameters using neighbors determined by
              this NearNeighbor class
  
          Returns: a pymatgen.analysis.graphs.MoleculeGraph object