Session Ready
Exercise

Build and explore the network (part 1)

In this exercise, you are going to begin using the igraph package. This package lets you analyze data that are represented as networks, which are also called graphs by mathematicians. In particular, you will learn how to build a network from a data frame and explore the nodes and ties of the network.

For your convenience, the package igraph and the data frames nodes and ties are already loaded into the workspace.

Instructions
100 XP
  • Use graph_from_data_frame() to create a network.
    • The first argument is the data frame of ties.
    • The directed argument is whether or not to make this a directed graph. This should be FALSE.
    • The vertices argument is the data frame of nodes.
  • Explore the nodes in g.
    • Call V() to extract the vertices from g.
    • Print the number of vertices with vcount().
  • Explore the ties in g.
    • Call E() to extract the edges from g.
    • Print the number of edges with ecount().