重叠边
社交网络的两个基本组成部分是节点和边。权重通常是正值。
数据集 edges 包含一个小型网络的边。同一对节点之间存在多条边,可能意味着这两个节点之间的连接比只有一条边更强。与其逐条显示每一条边,您可以让这些边重叠,并将 width 设为边的数量。
igraph 库和数据集 edges 已加载到您的工作区。
本练习是课程的一部分
R 中的欺诈检测
练习说明
- 使用
graph_from_data_frame()基于数据集edges创建一个名为net的「无向」图,并将directed设置为合适的布尔值(TRUE或FALSE)。 - 使用
plot()绘制网络net,并将layout设为layout_in_circle(不要加引号""!)。 - 为了获得重叠边,将
E(net)$width设为对net使用count.multiple()得到的多重边数量。通过将E(net)$curved设置为合适的布尔值(TRUE或FALSE)来「避免」出现弯曲边。 - 再次以圆形布局绘制
net。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Create a network from the data frame
net <- ___(___, directed = ___)
# Plot the network with the multiple edges
___(___, layout = ___)
# Specify new edge attributes width and curved
E(net)$___ <- ___
E(net)$___ <- ___
# Check the new edge attributes and plot the network with overlapping edges
edge_attr(net)
___(___, layout = ___)