Given a matrix that describes the edges' and their weights of a connected graph (see below) I want to extract a subgraph based on a threshold value x for the edges' weights. In literature, I read that one can search for the maximal x, such that the induced subgraph is connected.
Since the initial graph is assumed connected, there must be a critical threshold x-critical
that the extracted subgraph is connected for any x <= x-critical
.
I was wondering how can this implemented in R. For example, my matrix (weights.matrix
) looks like
| FROM | TO | WEIGHT |
| A | B | 0.0042 |
| A | V | 0.23 |
| G | W | 0.82 |
| ... | ...| ... |
and I'm creating the whole graph, by using the igraph package like:
g <- igraph::graph_from_data_frame(weights.matrix, directed = TRUE)
Is there any way to check repeatedly - by applying a different threshold value in the weights from min()
to max()
- if the occurred graph is connected? I searched in google for such feature in igraph but couldn't find anything helpful.
Here is some code for building such a graph.
library(igraph)
mat <- expand.grid(LETTERS[1:10], LETTERS[1:10])
mat$Weight <- runif(nrow(mat), 0.01, max = 1)
mat <- mat[mat$Var1!=mat$Var2, ]
g <- graph_from_data_frame(mat)
Also here is a paper referring that technique in pdf's page 15 , section 5 the fourth. You can consider the edge relevance as the edge weight discussed here.