code: def get_graph_segments(X, G):
      """Get graph segments for plotting a 2D graph
  
      Parameters
      ----------
      X : array_like
          the data, of shape [n_samples, 2]
      G : array_like or sparse graph
          the [n_samples, n_samples] matrix encoding the graph of connectinons
          on X
  
      Returns
      -------
      x_coords, y_coords : ndarrays
          the x and y coordinates for plotting the graph.  They are of size
          [2, n_links], and can be visualized using
          ``plt.plot(x_coords, y_coords, '-k')``
      """
      X = np.asarray(X)
      if (X.ndim != 2) or (X.shape[1] != 2):
          raise ValueError("shape of X should be (n_samples, 2)")
  
      G = sparse.coo_matrix(G)
      A = X[G.row].T
      B = X[G.col].T
  
      x_coords = np.vstack([A[0], B[0]])
      y_coords = np.vstack([A[1], B[1]])
  
      return x_coords, y_coords
  
file_path: astroML/astroML/clustering/mst_clustering.py
imports: import numpy
  from scipy import sparse
  from sklearn.base import BaseEstimator
  from sklearn.neighbors import kneighbors_graph
label_desc: Use image node_id 1 for calling a global function with example usage: get_graph_segments(X, G) and returns: x_coords,  y_coords