How to deal undirected dis-joint graph in igraph

I have a df containing 3 columns ( from, to, scr ). The from and to columns are the node and the scr is the score/weight column.

                                        from                                   to   scr
1                                    ID00309                                 ID00314 0.55
2                                    ID00309                                 ID00315 0.66
3                                    ID00309     FID00119 _ FSID012160 _ Riboflavine 0.97
4                                    ID00309     FID00099 _ FSID012160 _ Riboflavine 0.66
5                                    ID00310          FID00120 _ FSID009721 _ Lignin 0.55
6                                    ID00311 FID00120 _ FSID012362 _ beta-Sitosterol 0.34
7                                    ID00312       FID00038 _ FSID013505 _ Taraxerol 0.44
8                                    ID00313 FID00087 _ FSID012362 _ beta-Sitosterol 0.55
9                                    ID00313     FID00094 _ FSID013269 _ Cholesterol 0.23
10         FID00038 _ FSID013505 _ Taraxerol                                 ID00910 0.00
11 FID00120 _ FSID001304 _ alpha1-Sitosterol        FID00017 _ FSID004090 _ Atropine 1.00
12   FID00087 _ FSID012362 _ beta-Sitosterol       FID00038 _ FSID013505 _ Taraxerol 0.78

My Code

graph_datset <- df
graph_build <- graph_from_data_frame(graph_datset, directed = FALSE)
E(graph_build)$weight <- graph_datset$new_ssp
plot(graph_build, vertex.label = V(graph_build)$name)

# Calculating New link prediction using 'linkprediction'
  proxfun(graph_build, method="cos", value="matrix")

But, I am getting this error Error in proxfun.igraph(graph_build, method = "aa", value = "matrix") : graph has to be undirected and connected.

Actually, what does it mean?

My graph is already undirected but they are not connected (after visualize) I have found that that graph has 5 parts and they are not connected. But, it could happen, right? Because, maybe the node does not have any connections! So, they have gone apart from one another!

If the problem is for not connected then how can I solve the issue?

Reproducible Dataset

structure(list(Id_1 = structure(c(4L, 4L, 4L, 4L, 5L, 6L, 7L, 
8L, 8L, 1L, 3L, 2L), .Label = c("FID00038 _ FSID013505 _ Taraxerol", 
"FID00087 _ FSID012362 _ beta-Sitosterol", "FID00120 _ FSID001304 _ alpha1-Sitosterol", 
"ID00309", "ID00310", "ID00311", "ID00312", "ID00313"), class = "factor"), 
    Id_2 = structure(c(9L, 10L, 6L, 5L, 7L, 8L, 2L, 3L, 4L, 11L, 
    1L, 2L), .Label = c("FID00017 _ FSID004090 _ Atropine", "FID00038 _ FSID013505 _ Taraxerol", 
    "FID00087 _ FSID012362 _ beta-Sitosterol", "FID00094 _ FSID013269 _ Cholesterol", 
    "FID00099 _ FSID012160 _ Riboflavine", "FID00119 _ FSID012160 _ Riboflavine", 
    "FID00120 _ FSID009721 _ Lignin", "FID00120 _ FSID012362 _ beta-Sitosterol", 
    "ID00314", "ID00315", "ID00910"), class = "factor"), sim = c(0.55, 
    0.66, 0.97, 0.66, 0.55, 0.34, 0.44, 0.55, 0.23, 0, 1, 0.78
    )), row.names = c(NA, 12L), class = "data.frame")

Technically you could run the proxfun multiple times, one for each connected subgraph.
Whether the values that you get are useful for anything across the original disjoint graph is another question

@nirgrahamuk thank you for your nice idea. But, the problem is, I have a very large dataset, and I don't know, how many dis-joint graphs are in my dataset! Any idea for getting the number of dis-joint graphs and then applying the function?

Try this https://igraph.org/r/doc/decompose.html

and purrr package is good for iterating a function over elements of a list.