ãããã¯ã¼ã¯æ§é ã®åæ - ã³ãã¥ããã£ã®æ½åº
ããç¨åº¦ã®è¦æ¨¡ã®ãããã¯ã¼ã¯ã§ã¯ãå
é¨ã«ãµããããã¯ã¼ã¯ï¼ã³ãã¥ããã£ï¼ãå½¢æããããã¨ããã
ä¾ãã°ã大å¦ã®ãããã¯ã¼ã¯å³ãæãã¨ãä½ã¨ãªãå¦é¨ã ã£ãããµã¼ã¯ã«ã®ã°ã«ã¼ããè¦ãã¦ãã
ãã®ããªã³ãã¥ããã£ã®æ½åºæ¹æ³ã¨ãã¦ã辺ã®åªä»ä¸å¿æ§ãç¨ããæ¹æ³ãããã®ã§ããã®æ¹æ³ã¨Rã§ã®å®è¡ãç´¹ä»ãã
ãã¼ã¿ã®å ¥åã¨æç»
g <- graph(c( 1,2, 1,3, 1,4, 1,5, 1,9, 2,3, 2,4, 3,4, 5,6, 5,7, 5,9, 6,7, 6,8, 7,8) - 1, n = 9, directed = FALSE)
plot(g,layout=layout.lgl)
ä½ã¨ãªãã以ä¸ã®ãããªã³ãã¥ããã£ããããã
辺ã®åªä»ä¸å¿æ§
[R][ネットワーク分析] ネットワークにおいてどれくらい中心的かの指標 - yokkunsの日記ã®åªä»ä¸å¿æ§ããã¨ãã¸ã«é©ç¨ãããã®ã
ãã人ã¨ãã人ã®ã¤ãªãããé¤å¤ããã¨ãã³ãã¥ããã£éã®ã¤ãªããããªããªã£ãããé ããªããããªã¤ãªããã®ã¹ã³ã¢ãé«ããªã
Rã§ã¯ãigraphããã±ã¼ã¸ã®edge.betweennessé¢æ°ã§è¨ç®åºæ¥ã
(g.edge.betweenness <- edge.betweenness(g, directed=FALSE)) [1] 6 6 6 16 4 1 1 1 9 9 4 1 4 4
ã¨ãã¸ã«åªä»ä¸å¿æ§ã®å¤ãå ¥ããã¨ä»¥ä¸ã®ãããªæã
plot(g,layout=layout.fruchterman.reingold,edge.label=g.edge.betweenness)
辺ã®åªä»ä¸å¿æ§ã«ããåå²
åªä»ä¸å¿æ§ãæ大ã«ãªãã¨ãã¸ãåãé¤ãã¦åå²ãã¨ããã®ãç¹°ãè¿ã
> (eb <- edge.betweenness.community(g)) $removed.edges [1] 3 4 10 8 9 0 1 2 5 6 7 11 12 13 $edge.betweenness [1] 16.0 20.0 4.0 1.5 3.0 1.0 1.5 3.0 1.0 2.0 1.0 1.0 2.0 1.0 $merges [,1] [,2] [1,] 6 7 [2,] 5 9 [3,] 2 3 [4,] 1 11 [5,] 0 12 [6,] 4 10 [7,] 14 8 [8,] 13 15 $bridges [1] 14 13 11 10 8 5 3 2 attr(,"class") [1] "igraph.ebc"
eb$mergeã¯åãã¼ããååãã¦ã³ãã¥ããã£ãå½¢æãã¦ãéç¨ã示ãã¦ããã
æåã¯åãã¼ãã1ã¤ã®ã³ãã¥ããã£ã®ç¶æ
ããã¯ãã¾ãã6ã¨7ãã¤ãªãã£ã¦9ã¨ããã³ãã¥ããã£ãçæã次ã«ã5ã¨ãã®ã³ãã¥ããã£ãååãã¦ã»ã»ã»ã¨ããæµãã
ãã®æ§åã¯ããã³ããã°ã©ã ã®æ¹ãåããããã
dend <- as.dendrogram(eb) plot(dend)
ãã³ããã°ã©ã ãä»»æã®ã¹ãããæ°ã§åãã°ãããã¤ãã®ã³ãã¥ããã£ãå½¢æããã
è¦æ¹ã¨ãã¦ã¯ä»¥ä¸ã®ãããªæãã§ãåã¹ãããæ°ã§ã®ã³ãã¥ããã£ãåãã
ã¢ã¸ã¥ã©ãªãã£Q
辺ã®åªä»ä¸å¿æ§ãç¨ãããã¨ã§ãä»»æã®ã³ãã¥ããã£æ½åºãåºæ¥ãäºãåãã£ãããã©ã®ã¹ãããæ°ãæé©ãªã®ãã¯åãããªã
ä½ããã£ã¦æé©ã¨ãããã¯é£ããããä¸ã¤ã®æãããã¨ãã¦ãåå²ãããã³ãã¥ããã£å
ã®ã¤ãªããå
·åã¨ãã³ãã¥ããã£éã®ã¤ãªããå
·åãæ¯è¼ããã¢ã¸ã¥ã©ãªãã£Qã¨ããææ¨ããã
ã¨ãããããã¢ã¸ã¥ã©ãªãã£Qãæ大ã«ãªãåå²
# ã¢ã¸ã¥ã©ãªãã£Qãæ大ã«ãªãåå² wt <- walktrap.community(g,modularity=T) memb <- community.to.membership(g, wt$merges, steps=which.max(wt$modularity)-1) # ã³ãã¥ããã£æ¯ã«è²ãè¨å® V(g)$color <- rainbow(length(memb$csize))[memb$membership+1] # ãããã¯ã¼ã¯å³ã®æç» plot(g, layout=layout.fruchterman.reingold, edge.arrow.size=0.5)
ä»»æã®æ°ã§åå²
ã¢ã¸ã¥ã©ãªãã£Qã¯ãä¸ã¤ã®æãããã«ã¯ãªãããæ®éçãªå¦¥å½æ§ãæã£ã¦ãã訳ã§ãªã
ä»åã®ä¾ã§ã¯ããããã¯ã¼ã¯å³ããã³ããã°ã©ã ãè¦ãã¨ã8çªã¯å¥ã®ã³ãã¥ããã£ï¼1人ã ãã©ï¼ã¨ãã¦è¦ãæ¹ãèªç¶ã ã¨æããã
# 6ã¹ãããã§ã³ãã¥ããã£åå² memb2 <- community.to.membership(g, eb$merges, steps=6) # ã³ãã¥ããã£æ¯ã«è²ãè¨å® V(g)$color <- rainbow(length(memb2$csize))[memb2$membership+1] # ãããã¯ã¼ã¯å³ã®æç» plot(g, layout=layout.fruchterman.reingold, edge.arrow.size=0.5)