code: def alg_test_2():
      # Do we handle case of graph with too many connected components?
      np.random.seed(0)
      n = 100
      k = 5
      x = np.random.randn(n, 2)
      x[: int(0.3 * n)] += 10
      x[int(0.8 * n) :] -= 10
      G = knn(x, k)
      t = average_link_graph(G)
      u = t.split(2)
      assert u.max() == 2
  
file_path: nipy/nipy/algorithms/clustering/tests/test_hierarchical_clustering.py
imports: import math
  import numpy
  from numpy.random import randn
  from nipy.algorithms.graph.field import field_from_graph_and_data
  from nipy.algorithms.graph.graph import knn
  from ..hierarchical_clustering import average_link_graph, average_link_graph_segment, ward, ward_field_segment, ward_quick, ward_quick_segment, ward_segment
label_desc: Use image node_id 2 for calling a global function with example usage: alg_test_2() without return types