Network density and average path length
The first graph level metric you will explore is the density of a graph. This is essentially the proportion of all potential edges between vertices that actually exist in the network graph. It is an indicator of how well connected the vertices of the graph are.
Another measure of how interconnected a network is average path length. This is calculated by determining the mean of the lengths of the shortest paths between all pairs of vertices in the network. The longest path length between any pair of vertices is called the diameter of the network graph. You will calculate the diameter and average path length of the original graph g.
Deze oefening maakt deel uit van de cursus
Network Analysis in R
Oefeninstructies
- Using the function
edge_density()calculate the density of the graphgand assign this value to the vectorgd. - Use
diameter()to calculate the diameter of the original graphg. - Assign the average path length of
gtog.aplwith the functionmean_distance().
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
library(igraph)
# Get density of a graph
gd <- ___(g)
# Get the diameter of the graph g
___(g, directed = FALSE)
# Get the average path length of the graph g
g.apl <- ___(g, directed = FALSE)
g.apl