開始使用免費開始

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
___(___)
編輯並執行程式碼