一、請以你自己的經過簡化後的個人社會網絡為例(例如只包含幾個最重要的人、或只舉幾位代表性人物),繪製下列社會網絡圖,同時,請用簡單的文字介紹你個人的社會網絡。(24%)

library(igraph)
## 
## 載入套件:'igraph'
## 下列物件被遮斷自 'package:stats':
## 
##     decompose, spectrum
## 下列物件被遮斷自 'package:base':
## 
##     union
nodes <- c("me", "東", "詠", "琪", "徽", "喬", "父", "母")
edges <- data.frame(
  from = c("me", "me", "me", "me", "徽", "me", "me", "父", "詠", "me", "琪"),
  to   = c("詠", "東", "徽", "喬", "喬", "父", "母", "母", "東", "琪", "詠"),
  weight = c(6, 4, 7, 2, 4, 3, 3, 9, 3, 6, 4) 
)

g <- graph_from_data_frame(edges, vertices = nodes, directed = FALSE)

set.seed(123)
layout1 <- layout_with_fr(g)

V(g)$color <- ifelse(V(g)$name == "me", "red",
                     ifelse(V(g)$name == "詠", "orange", "skyblue"))

plot(g,
     layout = layout1,
     edge.width = E(g)$weight,
     edge.label = E(g)$weight,         
     edge.label.cex = 1.1,        
     vertex.size = 30,
     vertex.label.cex = 1.2,
     vertex.label.font = 2,
     vertex.label.color = "black",
     vertex.color = V(g)$color,
     main = "個人中心網絡圖")

網絡可分類為三大群,同班同學(詠、東、琪)三人、室友(徽、喬)兩人、家人(父、母)兩人。同班同學間易受修課重疊性而影響兩兩間的聯繫強度,我與詠、琪兩位同學修課重複性高因此有較強烈的聯繫,而詠佔據了核心的位置;室友間我與徽較常有話題所以聯繫強度高,而喬共同話題較少屬於邊陲位置;最後是家人方面,大學在外獨立生活,故與父母聯繫頻率較同儕之間少。
library(igraph)

people <- c("me", "東", "詠", "琪", "徽", "喬")
activities_short <- c("A1", "A2", "A3", "A4")
all_nodes <- c(people, activities_short)

types <- c(rep(TRUE, length(people)), rep(FALSE, length(activities_short)))

edges_bi <- data.frame(
  from = c("me", "東", "詠", "琪", "me", "詠", "琪", "me", "喬", "徽", "東", "me", "徽"),
  to   = c("A1", "A1", "A1", "A1", "A2", "A2", "A2", "A3", "A3", "A3", "A4", "A4", "A4")
)

g_bi <- graph_from_data_frame(edges_bi,
                              vertices = data.frame(name = all_nodes, type = types),
                              directed = FALSE)

layout2 <- layout_as_bipartite(g_bi)
layout2[,2] <- -layout2[,2] 

person_idx <- which(V(g_bi)$type == TRUE)
activity_idx <- which(V(g_bi)$type == FALSE)

layout2[person_idx, 1] <- seq(-4, 4, length.out = length(person_idx))
layout2[activity_idx, 1] <- seq(-4, 4, length.out = length(activity_idx))

V(g_bi)$color <- ifelse(V(g_bi)$type, "skyblue", "lightgreen")

par(mar = c(6, 4, 4, 2))

plot(g_bi,
     layout = layout2,
     vertex.size = 30,
     vertex.label.cex = 1.1,
     vertex.label.color = "black",
     vertex.label.font = 2,
     vertex.color = V(g_bi)$color,
     main = "雙元網絡(two-mode network))")

legend("bottom",
       legend = c("A1 = 就讀社會學系",
                  "A2 = 社研法課程同組",
                  "A3 = 同住",
                  "A4 = 喜愛打羽球"),
       horiz = TRUE,
       inset = -0.25,
       bty = "n",
       text.col = "darkgreen",
       cex = 0.9,
       xpd = TRUE)

我與詠、東、琪三人皆就讀社會學系;在社研法課程時我與詠、琪兩人同組別,因彼此間想法較一致;我和徽、喬共同租屋互相照料彼此;興趣方面,我和東、徽有時會相約前去打羽球強健體魄。
library(igraph)

# 定義節點
nodes <- c("me", "東", "詠", "琪", "徽", "喬")

# 定義每一種社會關係作為一組邊
# 學業關係(就讀社會學系)
soc_edges <- data.frame(
  from = c("me", "me", "me", "東", "詠", "東"),
  to   = c("東", "詠", "琪", "詠", "琪", "琪"),
  type = "soc"
)

# 小組關係(社研法課程同組)
group_edges <- data.frame(
  from = c("me", "詠", "琪"),
  to   = c("詠", "琪", "me"),
  type = "group"
)

# 室友關係
roommate_edges <- data.frame(
  from = c("me", "喬", "徽"),
  to   = c("喬", "徽", "me"),
  type = "roommate"
)

# 羽球關係
badminton_edges <- data.frame(
  from = c("me", "東", "徽"),
  to   = c("東", "徽", "me"),
  type = "badminton"
)

# 合併所有邊並計算「同一對人之間的總關係數」
all_edges <- rbind(soc_edges, group_edges, roommate_edges, badminton_edges)


all_edges_a <- data.frame(
  from = pmin(all_edges$from, all_edges$to),
  to   = pmax(all_edges$from, all_edges$to),
  type = all_edges$type
)

# 計算邊的多重性(幾種關係)
edge_summary <- aggregate(type ~ from + to, data = all_edges_a, FUN = length)
names(edge_summary)[3] <- "weight"

# 建立圖
g_multi <- graph_from_data_frame(edge_summary, vertices = nodes, directed = FALSE)

# 使用 Fruchterman-Reingold 佈局
set.seed(456)
layout_m <- layout_with_fr(g_multi)

# 畫圖
plot(g_multi,
     layout = layout_m,
     edge.width = E(g_multi)$weight * 2,  # 關係愈多,邊愈粗
     edge.label = E(g_multi)$weight,
     edge.label.cex = 1.1,
     vertex.size = 30,
     vertex.label.cex = 1.2,
     vertex.label.font = 2,
     vertex.label.color = "black",
     vertex.color = "skyblue",
     main = "多重網絡圖")

在多重網絡圖中,節點代表我與身邊的重要人際互動對象,邊的粗細代表我們之間的多重關係數量之不同。我與詠、琪,既為同班同學,亦是同組夥伴;我與東既是同學,也是羽球夥伴;我與徽則為室友,同時也會一起打羽球;喬則僅為室友,屬於單一互動類型。可以看出擁有多重角色的人通常在生活中更為核心,彼此互動頻繁且多元。

二、請以下列網絡圖來回答以下題目(20%):

nodes <- data.frame(
  id = 1:8
)
print(nodes)
##   id
## 1  1
## 2  2
## 3  3
## 4  4
## 5  5
## 6  6
## 7  7
## 8  8
edges <- data.frame(
  from = c(1,1,2,3,4,5,6,7,8),
  to   = c(2,5,3,6,6,4,7,8,5)
)
print(edges)
##   from to
## 1    1  2
## 2    1  5
## 3    2  3
## 4    3  6
## 5    4  6
## 6    5  4
## 7    6  7
## 8    7  8
## 9    8  5
adj_matrix <- matrix(0, nrow = 8, ncol = 8)

for(i in 1:nrow(edges)) {
  a <- edges$from[i]
  b <- edges$to[i]
  adj_matrix[a, b] <- 1
  adj_matrix[b, a] <- 1
}

rownames(adj_matrix) <- colnames(adj_matrix) <- as.character(1:8)
adj_matrix
##   1 2 3 4 5 6 7 8
## 1 0 1 0 0 1 0 0 0
## 2 1 0 1 0 0 0 0 0
## 3 0 1 0 0 0 1 0 0
## 4 0 0 0 0 1 1 0 0
## 5 1 0 0 1 0 0 0 1
## 6 0 0 1 1 0 0 1 0
## 7 0 0 0 0 0 1 0 1
## 8 0 0 0 0 1 0 1 0
g <- graph_from_data_frame(edges, vertices = nodes, directed = FALSE)

is_directed(g)
## [1] FALSE
density_value <- edge_density(g)
paste("網絡的密度(density) =", round(density_value, 4))
## [1] "網絡的密度(density) = 0.3214"
上圖是undirected network,;網絡的密度(density)約為0.3214
degree(g)["6"]
## 6 
## 3
library(igraph)

edges <- data.frame(
  from = c(1,1,2,3,4,5,6,7,8),
  to   = c(2,5,3,6,6,4,7,8,5)
)

g <- graph_from_data_frame(edges, directed = FALSE)

deg <- degree(g)
btw <- betweenness(g)

data.frame(
  Betweenness = round(btw[c("3", "8")], 2)
)
##   Betweenness
## 3           3
## 8           2
node 6的degree是3;中介中心性是一種衡量節點在網絡中「橋樑角色」的重要指標,node 3和node 8與比較下, node 3的betweenness(中介性)大於 node 8,因此可推論node 3 比 node 8 更位於中心的位置。

三、在課堂中,我們曾經使用過下圖為例來說明中心性的概念。在圖中,節點上的數字代表這個節點的度數,請試著就你對於中心性概念的理解,回答下列問題。(16%)

四、請試著比較James和Robert在社會網絡位置上的同與異。(10%)

兩者的共同點在於皆位於資訊流通的關鍵節點,能影響不同成員之間的連結與互動,不論是作為群體內的核心人物(James),或作為群體間的橋樑(Robert),他們皆具有潛在的社會資本與影響力。James 的位置屬於群體 B 的核心,擁有較高的度中心性(degree centrality ),與許多成員直接連結,可能是群體意見領袖或資訊集中者,得迅速接收與傳播群體內的資訊。Robert 處於群體 A、B 與 C 之間的邊緣橋梁,雖然與每個群體的連結數量不多,但其連結的是彼此間缺乏聯繫的群體,具備高中介中心性(betweenness centrality),使他成為跨群體溝通的關鍵中介,擁有跨越結構洞的能力,掌握獨特且異質的資訊。綜合來看,James 擅長在群體內建立人脈與影響力,而 Robert 則擅長在群體之間搭橋連結。

五、請以一個社會網絡研究為例,簡要說明在不同分析層次下可能提出的研究問題。請舉出一個具體的社會網絡研究例子,並說明:(15%)

  研究:高中生的友誼網絡與背景變項之關係研究。研究者蒐集某校班級內學生之間的友誼連結,並結合他們的學業成績、性別等背景變項,建立社會網絡。

六、(加分題)就目前為止,針對這門社會網絡課或者是授課教師,你有什麼建議或心得呢?(3分)

    在社會網絡課程中,我瞭解到網絡是一種思考社會系統的方式,關注構成系統的實體間的關係,以及使用網絡視覺化能實際看出每個人如何在網絡中扮演不同角色,是量化分析無法看出來的,這對研究視野十分有幫助。另外對於初次使用R軟體的我,認為老師教授的難易度算是平易近人,有努力的話多半能夠很快上手,能夠在這堂課學到另一個軟體程式十分開心。最後對於作業的部分有項建議,希望老師能夠在學期期間批改作業,學生較能瞭解到是否有哪些地方較不熟悉需要多練習或調整。謝謝老師這學期的認真教導,您辛苦了!