Forrest Gump network
In this chapter you will use a social network based on the movie Forrest Gump. Each edge of the network indicates that those two characters were in at least one scene of the movie together. Therefore this network is undirected. To familiarize yourself with the network, you will first create the network object from the raw dataset. Then, you will identify key vertices using a measure called eigenvector centrality. Individuals with high eigenvector centrality are those that are highly connected to other highly connected individuals. You will then make an exploratory visualization of the network.
Cet exercice fait partie du cours
Network Analysis in R
Instructions
- Inspect the first few rows of the dataframe
gump
usinghead()
. - Make an undirected network using
graph_from_data_frame()
. - Identify the key vertices using the function
eigen_centrality()
and assign the results of this to the objectg.ec
. Next identify which individual has the highest eigenvector centrality usingwhich.max()
. The values of the centrality scores are stored ing.ec$vector
. - Make a plot of the Forrest Gump Network using
plot()
. Make the size of the vertices equal to 25 times the eigenvector centrality values that are stored ing.ec$vector
.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
library(igraph)
# Inspect Forrest Gump Movie dataset
head(gump)
# Make an undirected network
g <- ___(gump, directed = FALSE)
# Identify key nodes using eigenvector centrality
g.ec <- ___(g)
___(g.ec$vector)
# Plot Forrest Gump Network
plot(g,
vertex.label.color = "black",
vertex.label.cex = 0.6,
vertex.size = 25*(___),
edge.color = 'gray88',
main = "Forrest Gump Network"
)