Session Ready
Exercise

Visualizing edges

In this exercise you will learn how to change the size of edges in a network based on their weight, as well as how to remove edges from a network which can sometimes be helpful in more effectively visualizing large and highly clustered networks. In this introductory chapter, we have just scratched the surface of what's possible in visualizing igraph networks. You will continue to develop these skills in future chapters.

Instructions
100 XP
  • Create a vector w1 of edge weights based on the number of hours friends spend together.
  • Plot the network ensuring that the edge.width is set to the vector of weights you just created. Using edge.color = 'black' ensures that all edges will be black.
  • Next, create a new graph object g2 that is the g1 network but with all edges of that are of weight less than two hours removed. This is done by using delete_edges() which takes two arguments. The first is the graph object and the second is the subset of edges to be removed. In this case, you will remove any edges that have a value of less than two hours.
  • Finally, plot the new network g2 using the appropriate vector of edge widths and layout.