Function returns an adjacency matrix based on the euclidean distance of each gene's expression across all cells
    :param traj_dist: ndarray of euclidean distances
    :param k: int of the minimum number of connections needed for a minimally connected graph, calculated by min_conn_k()
    :return adj_mat: ndarray representing the calculated adjacency matrix

def adaptive_knn_graph(traj_dist,k): 
    '''
    Function returns an adjacency matrix based on the euclidean distance of each gene's expression across all cells
    :param traj_dist: ndarray of euclidean distances
    :param k: int of the minimum number of connections needed for a minimally connected graph, calculated by min_conn_k()
    :return adj_mat: ndarray representing the calculated adjacency matrix
    '''
    adj_mat = np.zeros_like(traj_dist,dtype=float) #initialize output matrix
    knn=(np.transpose(np.argsort(traj_dist,0))) #returns the indices that would sort an array, transposed for consistent formatting
    for i in range(0,(traj_dist.shape[0])): #go through the whole distance matrix and set the corresponding adjacencies
        adj_mat[i,knn[i,range(1,k)]]=traj_dist[i,knn[i,range(1,k)]]
    return adj_mat