I have an weighted adjacency matrix m and I need the find the shortest path matrix. The expected result is:

library(igraph)
n = 8
m <- t(matrix(c(
0,0,0,0,0,0,0,8,
3,0,0,0,0,0,0,0,
5,0,0,5,1,0,0,0,
0,0,6,0,0,7,1,0,
0,6,2,0,0,0,0,0,
0,0,0,0,0,0,0,0,
7,4,0,0,8,0,0,3,
0,3,0,0,0,9,0,0),ncol=n))
g1 <- graph_from_adjacency_matrix(m, weighted=TRUE, mode="directed")
V(g1)$names <- letters[1:n]
plot(g1, vertex.label = V(g1)$names, edge.arrow.size=0.5)
My attept is:
path_name <- c()
for (i in c(1,2,6,8)){
for (path in all_simple_paths(g1, i, V(g1), mode="out")) {
path_name <- c(path_name, paste(V(g1)[path]$names, collapse=''));
}
}
path_name
[1] "ah" "ahb" "ahf" "ba" "bah" "bahf" "hb" "hba" "hf"
One can see that I have found the paths just for four nodes: 1, 2, 5, 6 with names a, b, f, h. If we take a, b, h as a start node we can obtain 3 paths for each node while for h no path.
Question. How to reconstruct the paths for all nodes? I don't found the Lee (wave) algoritms.