def astar_len(adj, start, target): G = nx.from_numpy_matrix(adj) return nx.astar_path_length(G, start, target) # Data