可视化节点属性
网络的结构通常取决于其中节点所具有的属性。能够在图中可视化这些属性,有助于发现模式,并更好地理解数据中的关系。为节点使用不同的颜色和形状,是在图中呈现此类信息的有效方式。节点属性 account type 可取 3 个不同的值,我们将根据该属性定义 3 种不同的颜色。
工作区中已提供网络 net。上一练习更新后的 V(net)$account_type 对象也已可用:每个节点都是类型为 1、2 或 3 的账户。
本练习是课程的一部分
R 中的欺诈检测
练习说明
- 创建对象
vertex_colors,按顺序包含颜色"grey"、"lightblue"和"darkorange"。 - 为
V(net)添加属性color,其值根据account_type为每个节点指定对应的颜色。 - 绘制网络
net,并显示其新的节点属性。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Each account type is assigned a color
___ <- c(___, ___, ___)
# Add attribute color to V(net) which holds the color of each node depending on its account_type
___ <- ___[___(___)$___]
# Plot the network
___