User Tools

Site Tools


centrality

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
centrality [2015/11/24 09:15] – created hkimscilcentrality [2024/11/18 10:44] (current) – [Eigenvector] hkimscil
Line 4: Line 4:
  
 ===== Closeness ===== ===== Closeness =====
 +<code>setwd("D:/Users/Hyo/Cs-Kant/CS/Classes/sna_examples/sna_in_r")</code>
 <code># Social Network Analysis: Closeness Centrality   <code># Social Network Analysis: Closeness Centrality  
 library(sna) library(sna)
Line 19: Line 20:
 </code> </code>
  
-<code>gplot(L, displaylabels = T, vertex.cex = 1, label.cex = 2, edge.col="red",  +<code>gplot(L, displaylabels = T, vertex.cex = 1, label.cex = 2, edge.col="blue",  
-             boxed.labels = F, arrowhead.cex = 1, mode = "kamadakawai")+boxed.labels = F, arrowhead.cex = 1, mode = "kamadakawai")
 </code> </code>
 {{centrality_suzuki.png}} {{centrality_suzuki.png}}
Line 53: Line 54:
 </code> </code>
 {{knoke_info.png}} {{knoke_info.png}}
 +  - COUN: county government
 +  - COMM: chamber of commerce
 +  - EDUC: board of education
 +  - INDU: Industry development agency
 +  - MAYR: Mayor
 +  - WRO: Women Right Organization group
 +  - NEWS: Newspaper 
 +  - WAY: United Way (private organization)
 +  - WELF: Welfare
 +  - WEST: West group (private organization)
  
-COUN: county government +for out link (information out)
-COMM: chamber of commerce +
-EDUC: board of education +
-INDU: Industry development agency +
-MAYR: Mayor +
-WRO: Women Right Organization group +
-NEWS: Newspaper  +
-WAY: United Way (private organization) +
-WELF: Welfare +
-WEST: West group (private organization) +
- +
- +
 <code>round(closeness(knoke.infor,cmode="suminvdir"),2) <code>round(closeness(knoke.infor,cmode="suminvdir"),2)
  [1] 0.70 0.89 0.83 0.70 0.94 0.63 0.65 0.81 0.65 0.78  [1] 0.70 0.89 0.83 0.70 0.94 0.63 0.65 0.81 0.65 0.78
 </code> </code>
 +for in link (information in)
 <code>round(closeness(t(knoke.infor),cmode="suminvdir"),2) <code>round(closeness(t(knoke.infor),cmode="suminvdir"),2)
  [1] 0.76 0.94 0.72 0.78 0.94 0.46 1.00 0.59 0.78 0.61  [1] 0.76 0.94 0.72 0.78 0.94 0.46 1.00 0.59 0.78 0.61
Line 76: Line 76:
  
 ===== Betweenness ===== ===== Betweenness =====
 +노드 k에 대해서 노드 i 과 j 의 최단 경로 사이에 끼이게 되는 경우의 총합
 +
 +<code># Social Network Analysis: Betweenness Centrality 
 +library(sna)
 +
 +# The nearly linear network
 +L <- matrix(c(0,0,0,1,0,0,0,0,0,
 +              0,0,0,1,0,0,0,0,0,
 +              0,0,0,1,0,0,0,0,0,
 +              1,1,1,0,1,0,0,0,0,
 +              0,0,0,1,0,1,0,0,0,
 +              0,0,0,0,1,0,1,0,0,
 +              0,0,0,0,0,1,0,1,0,
 +              0,0,0,0,0,0,1,0,1,
 +              0,0,0,0,0,0,0,1,0),byrow=T,nrow=9)
 +gplot(L, displaylabels=T, vertex.cex=1, label.cex=1, 
 +      edge.col="red", boxed.labels=F, arrowhead.cex=1, 
 +      mode="kamadakawai")
 +</code>
 +
 +<code>betweenness(L)
 +</code>
 +<code>[1]  0  0  0 36 32 30 24 14  0
 +</code>
 +
 +<code># The star network
 +S <- matrix(c(0,1,1,1,1,1,1,1,1,
 +              1,0,0,0,0,0,0,0,0,
 +              1,0,0,0,0,0,0,0,0,
 +              1,0,0,0,0,0,0,0,0,
 +              1,0,0,0,0,0,0,0,0,
 +              1,0,0,0,0,0,0,0,0,
 +              1,0,0,0,0,0,0,0,0,
 +              1,0,0,0,0,0,0,0,0,
 +              1,0,0,0,0,0,0,0,0),byrow=T,nrow=9)
 +gplot(S, displaylabels=T, vertex.cex=1, label.cex=1, 
 +      edge.col="red", boxed.labels=F, arrowhead.cex=1, 
 +      mode="kamadakawai")
 +</code>
 +{{star_between.png}}
 +
 +<code>betweenness(S)
 +</code>
 +<code>[1] 56  0  0  0  0  0  0  0  0
 +</code>
 +
 +<code># Two stars network
 +twostars <- matrix(0,13,13)
 +edges <- matrix(c(1,2,1,3,1,4,1,5,1,6,
 +                  6,7,7,8,8,13,9,13,10,13,11,13,12,13),
 +                  byrow=T,ncol=2)
 +twostars[edges] <- 1
 +twostars <- twostars + t(twostars) - twostars * t(twostars)
 +
 +gplot(twostars, displaylabels=T, vertex.cex=1, label.cex=1, 
 +      edge.col="red", boxed.labels=F, arrowhead.cex=1, mode="kamadakawai")
 +betweenness(twostars)
 +closeness(twostars)
 +</code>
 +{{two_star_network.png}}
 +
 +<code>>> betweenness(twostars)
 + [1] 76  0  0  0  0 70 72 70  0  0  0  0 76
 +> round(closeness(twostars),2)
 + [1] 0.35 0.27 0.27 0.27 0.27 0.39 0.40 0.39 0.27 0.27 0.27 0.27 0.35
 +</code>
 +
 +===== Eigenvector =====
 +__Eigenvector Centrality__
 +  * 중요한 노드에 연결된 노드가 중요하다는 관점
 +  * That is, the centrality of each node i is proportional to the sum of the centrality of its neighbors.
 +
 +<code>rownames(knoke.infor)
 +</code>
 +
 +<code>> rownames(knoke.infor) 
 + [1] "COUN" "COMM" "EDUC" "INDU" "MAYR" "WRO"  "NEWS" "UWAY" "WELF" "WEST"
 +</code>
 +
 +<code>round(evcent(knoke.infor),2)
 +</code>
 +
 +<code>> round(evcent(knoke.infor),2)
 + [1] 0.25 0.41 0.36 0.26 0.47 0.15 0.22 0.35 0.21 0.33
 +</code>
 +
 +<code>round(evcent(t(knoke.infor)),2)
 +</code>
 +
 +<code>> round(evcent(t(knoke.infor)),2)
 + [1] 0.30 0.45 0.21 0.34 0.45 0.04 0.46 0.18 0.28 0.13
 +</code>
 +
  
centrality.1448325901.txt.gz · Last modified: 2015/11/24 09:15 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki