3D 社群網路圖
最後,在這個練習中你會用 threejs 建立一個可互動的圖形,並依照 fast-greedy 社群偵測方法產生的社群成員資格來配置各個節點。
本練習屬於課程
R 的 Network Analysis
練習說明
- 在社群 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
___(___)