I analyze an undirected graph in R. I try (in the end) to write a function to get the ratio of the size (number of vertices) of the largest connected component to the size of the largest biconfection component - from any random graph. I was able to extract the size of the largest related component, but I had problems with the size of the largest component with binoculars. I started using the igraph biconnected_components function on g chart:
bicomponent_list <- biconnected_components(g)
bicomponent_list$components
length(bicomponent_list$components[[1]])
Then my half-baked idea was to sort this list somehow while decreasing the number of vertices so that I could always call length (bicomponent_components $ components [[1]]), and this would be the largest binary-connected component. But I do not know how to sort it correctly. Maybe I need to convert it to a vector? But I also donβt know how to indicate that I want the number of vertices in the vector. Does anyone know or have a better way to do this? Many thanks!
library(igraph)
g1 <- barabasi.game(100, 1, 5)
V(g1)$name <- as.character(1:100)
g2 <- erdos.renyi.game(50, graph.density(g1), directed = TRUE)
V(g2)$name <- as.character(101:200)
g3 <- graph.union(g1, g2, byname = TRUE)
bicomponent_list <- biconnected_components(g3)
bi_list <- as.list(bicomponent_list$components)
bi_list <- lapply(bi_list, length)
My desired result will be arranged bi_listin such a way that it length(bicomponent_list$components[[1]])returns the two-component with the highest number of vertices.
source
share