開始使用免費開始

找出關鍵頂點

評估頂點重要性最直觀的指標,就是頂點的度數。頂點的外出度(out-degree)是指該頂點指向其他個體的出邊數量;內入度(in-degree)則是從其他個體指向該頂點的邊數量。在麻疹傳播網路中,感染許多其他人的個體會有較高的外出度。在這個練習中,你要判斷個體是否大致感染了相同數量的其他孩童,或是是否存在外出度特別高、能感染許多其他孩童的關鍵孩童。

本練習屬於課程

R 的 Network Analysis

檢視課程

練習說明

  • 使用函式 degree() 計算每個頂點的外出度。第一個引數是網路圖物件,第二個引數 mode 應為 outinall 其中之一。將輸出指定給物件 g.outd
  • 對向量物件 g.outd 使用函式 table(),檢視所有個體外出度的摘要。
  • 對向量物件 g.outd 使用函式 hist(),繪製外出度的直方圖。
  • 對向量物件 g.outd 使用函式 which.max(),找出網路中外出度最高的是哪個頂點。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

library(igraph)

# Calculate the out-degree of each vertex
___ <- ___(g, mode = c("___"))

# View a summary of out-degree
___(g.outd)

# Make a histogram of out-degrees
___(g.outd, breaks = 30)

# Find the vertex that has the maximum out-degree
___(g.outd)
編輯並執行程式碼