重疊的邊
社群網路的兩個基本組成要素是節點與邊。權重通常為正值。
資料集 edges 包含一個小型網路的邊。兩個節點之間若有多條邊,可能代表這兩個節點的連結比只有一條邊時更強。與其分別顯示每一條邊,你可以讓邊重疊,並將 width 設為邊的數量。
igraph 函式庫與資料集 edges 已載入你的工作環境。
本練習屬於課程
R 的詐欺偵測
練習說明
- 使用
graph_from_data_frame()根據資料集edges建立一個名為net的「無向」圖,並將directed設為正確的布林值(TRUE或FALSE)。 - 使用
plot()繪製網路net,並將layout設為layout_in_circle(不要加引號""!)。 - 若要得到重疊的邊,對
net使用count.multiple(),將結果指定給E(net)$width。為了「避免」曲線邊,將E(net)$curved設為正確的布林值(TRUE或FALSE)。 - 再次以圓形配置繪製
net。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Create a network from the data frame
net <- ___(___, directed = ___)
# Plot the network with the multiple edges
___(___, layout = ___)
# Specify new edge attributes width and curved
E(net)$___ <- ___
E(net)$___ <- ___
# Check the new edge attributes and plot the network with overlapping edges
edge_attr(net)
___(___, layout = ___)