At vector.pmt:444 : cannot reserve space for vector, Out of memory

I have a large graph (vertex# 9,634 and edges# 454,691). I am using shortest.paths() function to get the shortest path matrix.

But, unfortunately, I am getting an error, At vector.pmt:444 : cannot reserve space for vector, Out of memory.

I am using R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Memory: 64 GB

Sample code is given below:
test <- read.csv("~/data.csv")

g1 <- test[1:5,]
graph1 <- graph_from_data_frame(g1, directed = FALSE)
E(graph1)$weight <- is.numeric(g1$weight)

mat_1 <- shortest.paths(graph1) # getting error in this line

I have gone through several posts and found one piece of information here but this code is not fulfilling my purpose. I need the whole matrix and then I have to do some filter in this matrix. For example, after getting the whole matrix, I will take only the cell values which have 2.

Badly need your help and suggestion.

For your kind information: I am also trying to use 87GB in a cluster but getting the same error!

Cross-posted at At vector.pmt:444 : cannot reserve space for vector, Out of memory · Issue #456 · igraph/rigraph · GitHub.

Since this is a support question, not a bug report, it is best to continue the discussion here.