Skip to content

Instantly share code, notes, and snippets.

@shirayuca
Created July 7, 2020 14:56
Show Gist options
  • Save shirayuca/24d9b9dd1c0a3f2591f7525eab00acc9 to your computer and use it in GitHub Desktop.
Save shirayuca/24d9b9dd1c0a3f2591f7525eab00acc9 to your computer and use it in GitHub Desktop.
情報学特殊講義A_09回(コミュニティ、鈴木努『ネットワーク分析 第2版 (Rで学ぶデータサイエンス) 』共立出版、2017年参照)
# ライブラリの準備
install.packages("igraph")
install.packages("linkcomm")
library(igraph)
library(linkcomm)
# データの準備
d <- read.csv("08_imotodesse.csv", header=T)
g <- d[1:2]
# 分割密度が最大になるようなリンクコミュニティの分割
lc <- getLinkCommunities(g, directed = T)
# 結果の出力
print(lc)
# 各ノードがどのリンクコミュニティに属するかを出力
write.csv(lc$nodeclusters, "community.csv", fileEncoding = "CP932")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment