docstr: Return a NetworkX Graph object representing the minimum spanning tree.
  
  Edge weights in the graph are the distance between the nodes they connect.
  
  Nodes have a `data` attribute attached giving the data vector of the
  associated point.
docstr_tok: ["Return","a","NetworkX","Graph","object","representing","the","minimum","spanning","tree",".","Edge","weights","in","the","graph","are","the","distance","between","the","nodes","they","connect",".","Nodes","have","a","`","data","`","attribute","attached","giving","the","data","vector","of","the","associated","point","."]
code: def to_networkx(self):
      """Return a NetworkX Graph object representing the minimum spanning tree.
  
      Edge weights in the graph are the distance between the nodes they connect.
  
      Nodes have a `data` attribute attached giving the data vector of the
      associated point.
      """
      try:
          from networkx import Graph, set_node_attributes
      except ImportError:
          raise ImportError(
              "You must have networkx installed to export networkx graphs"
          )
  
      result = Graph()
      for row in self._mst:
          result.add_edge(row[0], row[1], weight=row[2])
  
      data_dict = {
          index: tuple(row) for index, row in enumerate(self._data)
      }
      set_node_attributes(result, data_dict, "data")
  
      return result
  
imports: import numpy
  from scipy.cluster.hierarchy import dendrogram
  from sklearn.manifold import TSNE
  from sklearn.decomposition import PCA
  from sklearn.metrics import pairwise_distances
  from warnings import warn
  from ._hdbscan_tree import compute_stability, labelling_at_cut, recurse_leaf_dfs
label_desc: Use image node_id 5 for calling the MinimumSpanningTree obj's underlying member method code with example usage: obj.to_networkx() and returns: result