I have a symmetric matrix that represent degree of connections among actors. I would like to cancel out the vertex unconnected.
The functions included in igraph (as delete_edges or delete_vertices) do not work for my case. I share my code
#import of matrix
matrix3<-import("matrix2a.xlsx")
r.name <- matrix2a [,1]
rownames(matrix2a) <- r.name
matrix2a <- matrix2a %>% select(-X__1)
View(matrix2a)
m=as.matrix(matrix2a)
#I compute the maximum spanning tree graph
g <- graph_from_adjacency_matrix(m, mode = "upper", weighted = T, diag = F)
max_spann_tree <- mst(g, weights = -E(g)$weight)
#I obtain a network with some unconneted vertex that I would like to erase
thanks in advance for your help!
I am not sure what you mean "The functions included in igraph (as delete_edges or delete_vertices) do not work for my case."
delete.vertices
is made for precisely this purpose.Since you do not provide data, I will show a small example from random data. I am adding labels to the graph so that the numbering will not change when I delete the isolated vertices. I am also using an explicit layout so I can lay out the reduced graph in the same way for comparison.
Now identify the isolated vertices and use
delete.vertices
to remove them.The same graph but without the isolated vertices.
If this is not what you want, please be more explicit about why it does not work for your graph.