# how to deal undirected dis-joint graph in igraph

**URL:** <https://igraph.discourse.group/t/how-to-deal-undirected-dis-joint-graph-in-igraph/635>\
**Category:** Usage\
**Tags:** R\
**Created:** [19 February 2021 16:15 UTC](https://igraph.discourse.group/t/how-to-deal-undirected-dis-joint-graph-in-igraph/635 "2021-02-19T16:15:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![akib62](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@akib62](https://igraph.discourse.group/u/akib62)\
**Post date:** [19 February 2021 16:15 UTC](https://igraph.discourse.group/t/how-to-deal-undirected-dis-joint-graph-in-igraph/635/1 "2021-02-19T16:15:30Z")

</div>

I have a df containing 3 columns ( `from, to, scr` ). The `from and to` columns are the `node` and the `src` 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")
```
