class_docstr: A single linkage format dendrogram tree, with plotting functionality
  and networkX support.
  
  Parameters
  ----------
  linkage : ndarray (n_samples, 4)
      The numpy array that holds the tree structure. As output by
      scipy.cluster.hierarchy, hdbscan, of fastcluster.
class_docstr_tok: ["A","single","linkage","format","dendrogram","tree",",","with","plotting","functionality","and","networkX","support",".","Parameters","--","--","--","--","--","linkage",":","ndarray","(","n_samples",",","4",")","The","numpy","array","that","holds","the","tree","structure",".","As","output","by","scipy.cluster.hierarchy",",","hdbscan",",","of","fastcluster","."]
docstr: Return a NetworkX DiGraph object representing the single linkage tree.
  
  Edge weights in the graph are the distance values at which child nodes
  merge to form the parent cluster.
  
  Nodes have a `size` attribute attached giving the number of points
  that are in the cluster.
docstr_tok: ["Return","a","NetworkX","DiGraph","object","representing","the","single","linkage","tree",".","Edge","weights","in","the","graph","are","the","distance","values","at","which","child","nodes","merge","to","form","the","parent","cluster",".","Nodes","have","a","`","size","`","attribute","attached","giving","the","number","of","points","that","are","in","the","cluster","."]
code: def to_networkx(self):
      """Return a NetworkX DiGraph object representing the single linkage tree.
  
      Edge weights in the graph are the distance values at which child nodes
      merge to form the parent cluster.
  
      Nodes have a `size` attribute attached giving the number of points
      that are in the cluster.
      """
      try:
          from networkx import DiGraph, set_node_attributes
      except ImportError:
          raise ImportError(
              "You must have networkx installed to export networkx graphs"
          )
  
      max_node = 2 * self._linkage.shape[0]
      num_points = max_node - (self._linkage.shape[0] - 1)
  
      result = DiGraph()
      for parent, row in enumerate(self._linkage, num_points):
          result.add_edge(parent, row[0], weight=row[2])
          result.add_edge(parent, row[1], weight=row[2])
  
      size_dict = {
          parent: row[3]
          for parent, row in enumerate(self._linkage, num_points)
      }
      set_node_attributes(result, size_dict, "size")
  
      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 SingleLinkageTree obj's underlying member method code with example usage: obj.to_networkx() and returns: result