def adaptive_knn_graph(traj_dist,k):
adj_mat = np.zeros_like(traj_dist,dtype=float) <EOL>knn=(np.transpose(np.argsort(traj_dist,<NUM_LIT:0>))) <EOL>for i in range(<NUM_LIT:0>,(traj_dist.shape[<NUM_LIT:0>])): <EOL><INDENT>adj_mat[i,knn[i,range(<NUM_LIT:1>,k)]]=traj_dist[i,knn[i,range(<NUM_LIT:1>,k)]]<EOL><DEDENT>return adj_mat<EOL>
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