Case Studies: Network Analysis in R
Edmund Hart
Instructor
rand_g <- erdos.renyi.game(10, 0.4, "gnp", directed = FALSE)
plot(rand_g)
rand_g <- erdos.renyi.game(10, 0.4, "gnp", directed = FALSE)
vertex_connectivity(rand_g)
2
edge_connectivity(rand_g)
2
min_cut(rand_g, value.only = FALSE)
$value
[1] 2
$cut
+ 2/18 edges from 17a8fad:
[1] 10--7 10--1
$partition1
+ 1/10 vertex, from 17a8fad:
[1] 10
$partition2
+ 9/10 vertices, from 17a8fad:
[1] 1 2 3 4 5 6 7 8 9
# Get parameters to simulate graph nv <- gorder(trip_g_ud) ed <- edge_density(trip_g_ud) # Empty vector to store output graph_vec <- rep(NA, 1000)
# Generate 1000 random graphs and find the edge connectivity for(i in 1:1000) { w1 <- erdos.renyi.game(nv, ed, "gnp", directed = TRUE) graph_vec[i] <- edge_connectivity(w1) }
# Find actual connectivity
econn <- edge_connectivity(trip_g_ud)
hist(graph_vec, xlim = c(0, 140))
abline(v = edge_connectivity(trip_g_ud))
Case Studies: Network Analysis in R