开始使用免费开始使用

3D 社区网络图

最后,在本练习中,您将使用 threejs 创建一个交互式图形,并根据快速贪婪社区检测方法得到的社区成员关系来布置顶点。

本练习是课程的一部分

R 中的网络分析

查看课程

练习说明

  • 在社区 igraph 对象 kc 上使用函数 membership(),为每个顶点生成其所属社区的向量。
  • 在社区 igraph 对象 kc 上使用函数 sizes(),查看共有多少个社区。
  • 使用 set_vertex_attr(),为图对象 g 添加名为 color 的顶点属性。要添加的取值是基于成员关系分配给对象 i 的颜色。
  • 在网络对象 g 上使用函数 graphjs(),绘制三维图。

交互式实操练习

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

# Create an object 'i' containin the memberships of the fast-greedy community detection
i <-  ___(kc)

# Check the number of different communities
___(kc)

# Add a color attribute to each vertex, setting the vertex color based on community membership
g <- ___(___, "___", value = c("yellow", "blue", "red")[i])

# Plot the graph using threejs
___(___)
编辑并运行代码