def graph2data(graph):
    """Returns the index and data of a sparse matrix.

    Parameters
    ----------
    graph : csr_matrix
        A sparse matrix of the edges in a graph and corresponding node indexes.

    Returns
    -------
    index1, index2 : array
        Arrays of the node indices of the graph.
    weights : array
        An array of the weights of each edge in the graph.
    """
    graph = graph.tocoo()
    weights = graph.data
    index1 = graph.row
    index2 = graph.col
    return index1, index2, weights