Starting from the Adjacency Matrix with igraph

To avoid mistakes and confusion, it is better to detach the statnet package because there exist similar functions to the ones of the igraph package. If we do not detach the statnet package, we have to use the prefix network:: to specify that the function is from the network package (which is included in the statnet package).

detach(package:statnet)
p_load(igraph)

Now, the starting point is the adjacency matrix again. This is equal to what has been done before.

adjacency_matrix <- rbind(
  c(0,1,1,0,0),
  c(0,0,1,1,0),
  c(0,1,0,0,0),
  c(0,0,0,0,0),
  c(0,0,1,0,0)
)

Creating a Network Object

Now that we have our matrix, we can create a network object from it using the graph.adjacency() function from the igraph package:

adjacency_network <- graph.adjacency(adjacency_matrix)

Checking the Network Object

To confirm that our network object was created successfully, we can check its class type with the class() function:

class(adjacency_network)
[1] "igraph"

We can also use the summary() function to get more information about the network, such as the number of vertices and edges:

summary(adjacency_network)
IGRAPH 50042ad DN-- 5 6 --
+ attr: name (v/c)

Understanding the Summary Output

Multiple choice

A network is created using igraph. The output of the summary() function returns 53ecc7b UN-B 8 12 -- attr: name (e/n) as output. Assign the correct answer to the MC variable (1, 2, 3 or 4).

  1. The network is a directed and bipartite one.
  2. The network is not weighted, and bipartite.
  3. The network has 8 edges and 12 vertices.
  4. The network has a logical type attribute.