R language draws bipartite network connectivity graph

g3 <- make_star(10, mode = "in")
V(g3)$name <- letters[1:10]
plot(g3)

insert image description here

library(igraph)
g <- make_ring(10)
as_ids(V(g))
as_ids(E(g))
V(g)$name <- letters[1:10]
as_ids(V(g))
as_ids(E(g))
plot(g)

insert image description here

g <- make_bipartite_graph(c(0, 1, 0, 1, 0, 0), c(1, 2, 2, 3, 3, 4))
as_incidence_matrix(g)
plot(g)

insert image description here

g <- (make_full_graph(10) + make_full_graph(10)) %>%
  rewire(each_edge(p = 0.2))
correct <- rep(1:2, each = 10) %>% as_membership()
fc <- cluster_fast_greedy(g)
plot(g)

insert image description here

compare(correct, fc)
[1] 0.3300913
compare(correct, membership(fc))
[1] 0.3300913

library(igraph)
g <- disjoint_union(make_full_graph(5), make_full_graph(5))
clu <- components(g)$membership
g <- add_edges(g, c(which(clu == 1), which(clu == 2)))
bc <- biconnected_components(g)
plot(g)

insert image description here

g3 <- make_ring(10)
g3 <- add_edges(g3, c(1, 3))
bipartite_mapping(g3)
plot(g3)

insert image description here
Development tool: RStudio
Reference: "Network Analysis and Visualization"

Guess you like

Origin blog.csdn.net/m0_38127487/article/details/132103322