开始使用免费开始使用

Create a network from an edgelist

In this exercise, you will create a network from an edgelist.

You will create an igraph object from data stored in an edgelist using the function graph_from_data_frame(). The data is a social network of customers and each row of the edgeList dataframe represents an edge in the network. The edges in this network are undirected and have weight 1. This is indicated by the directed argument of the function, which is logical so the value FALSE means that the network is undirected.

The igraph package has been loaded for you.

本练习是课程的一部分

Predictive Analytics using Networked Data in R

查看课程

练习说明

  • Inspect the first rows of the edgeList dataframe using the head() function.
  • Create an igraph object called network with the edgeList dataframe using the graph_from_dataframe() function. Use the logical directed argument to specify that the network is undirected.
  • Inspect the igraph object you created by calling its name.

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Inspect edgeList
head(___)

# Construct the igraph object
network <- graph_from_data_frame(___, directed = ___)

# View your igraph object
___
编辑并运行代码