We will be using the article assigned as a reading for Lesson 5 (Koschade, Stuart. 2006. A Social Network Analysis of Jemaah Islamiyah: The Applications to Counterterrorism and Intelligence . Studies in Conflict and Terrorism. Vol. 29 Issue 6, pp. 559 - 575) for this assignment as well. The data from this paper (tables 1 and 2) are available to you as the following CSV file: . Table 1 . Table 2
After reading the article, perform the following: 1. Read in the data and plot the network similar to the one shown in Figure 1 of the article.
library(igraph)
##
## Attaching package: 'igraph'
## The following objects are masked from 'package:stats':
##
## decompose, spectrum
## The following object is masked from 'package:base':
##
## union
Table1 <- read.csv('846 Lesson 5 2006 Koschade Table 1.csv', header=TRUE, row.name=1)
Table2 <- read.csv('846 Lesson 5 2006 Koschade Table 2.csv', header=TRUE, row.name=1)
head(Table1)
## Muklas Amrozi Imron Samudra Dulmatin Idris Mubarok Azahari Ghoni
## Muklas 0 1 1 1 1 1 0 1 1
## Amrozi 1 0 0 1 0 1 1 0 0
## Imron 1 0 0 1 1 1 0 1 1
## Samudra 1 1 1 0 1 1 1 1 1
## Dulmatin 1 0 1 1 0 1 0 1 1
## Idris 1 1 1 1 1 0 1 1 1
## Arnasan Rauf Octavia Hidayat Junaedi Patek Feri Sarijo
## Muklas 0 0 0 0 0 1 0 1
## Amrozi 0 0 0 0 0 0 0 0
## Imron 0 0 0 0 0 1 1 1
## Samudra 1 1 1 1 1 1 0 1
## Dulmatin 0 0 0 0 0 1 1 1
## Idris 0 0 0 0 0 1 0 1
dim(Table1)
## [1] 17 17
head(Table2)
## Muklas Amrozi Imron Samudra Dulmatin Idris Mubarok Azahari Ghoni
## Muklas 0 2 2 1 1 5 0 1 1
## Amrozi 2 0 0 2 0 4 5 0 0
## Imron 2 0 0 3 5 3 0 5 5
## Samudra 1 2 3 0 2 5 2 2 2
## Dulmatin 1 0 5 2 0 2 0 5 5
## Idris 5 4 3 5 2 0 2 2 2
## Arnasan Rauf Octavia Hidayat Junaedi Patek Feri Sarijo
## Muklas 0 0 0 0 0 1 0 1
## Amrozi 0 0 0 0 0 0 0 0
## Imron 0 0 0 0 0 5 1 5
## Samudra 2 2 2 2 2 2 0 2
## Dulmatin 0 0 0 0 0 5 1 5
## Idris 0 0 0 0 0 2 0 2
dim(Table2)
## [1] 17 17
Plot the network
relations <- as.matrix(read.csv('846 Lesson 5 2006 Koschade Table 2.csv', header =T, row.names = 1))
g <- graph.adjacency(relations, mode = "undirected", weighted = TRUE)
summary(g)
## IGRAPH 9f50cd8 UNW- 17 63 --
## + attr: name (v/c), weight (e/n)
plot(g, layout = layout_with_kk, vertex.label.cex = 0.75, edge.width=E(g)$weight)
2. Use the following cohesive subgroup measures for identifying the following key structures within the network: a. Components
#Are networks weakly or strongly connected
weakly_connected_g <- is.connected(g, mode="weak")
strongly_connected_g <- is.connected(g, mode="strong")
#Get the number of (weakly or strongly) connected components
number_weak_components_g <- clusters(g, mode="weak")$no
size_weak_components_g <-clusters(g, mode="weak")$csize
members_weak_components_g <- clusters(g, mode="weak")$membership
number_strong_components_g <- clusters(g, mode="strong")$no
size_strong_components_g <-clusters(g, mode="strong")$csize
members_strong_components_g <- clusters(g, mode="strong")$membership
cat("Summary of component measures for first network: \n",
"Is weakly connected? ", weakly_connected_g, "\n",
"Is strongly connected? ", strongly_connected_g, "\n",
"Number of weak components: ", number_weak_components_g, "\n",
"Size of weak components: ", size_weak_components_g, "\n",
"Member of weak components: ", members_weak_components_g, "\n",
"Number of strong components: ", number_strong_components_g, "\n",
"Size of strong components: ", size_strong_components_g, "\n",
"Member of strong components: ", members_strong_components_g, "\n\n")
## Summary of component measures for first network:
## Is weakly connected? TRUE
## Is strongly connected? TRUE
## Number of weak components: 1
## Size of weak components: 17
## Member of weak components: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## Number of strong components: 1
## Size of strong components: 17
## Member of strong components: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
# List of cliques, their sizes and cliques with largest number of nodes
cliques_g <- cliques(g, min=3)
clique_sizes_g <- sapply(cliques_g, length)
largest_cliques_g <- largest_cliques(g)
cat("Summary of clique measures (smallest clique size 3) for first network: \n",
"Number of cliques: ", length(cliques_g), "\n",
"Cliques ", paste(cliques_g[[1]]), "\n",
" ", paste(cliques_g[[2]]), "\n",
" ", paste(cliques_g[[3]]), "\n",
" ", paste(cliques_g[[4]]), "\n",
" ", paste(cliques_g[[5]]), "\n",
" ", paste(cliques_g[[6]]), "\n",
"Clique sizes ", paste(clique_sizes_g), "\n",
"Largest clique: ", paste(largest_cliques_g), "\n")
## Summary of clique measures (smallest clique size 3) for first network:
## Number of cliques: 573
## Cliques 1 4 6
## 4 13 14
## 4 6 7
## 1 6 17
## 1 4 6 17
## 1 4 17
## Clique sizes 3 3 3 3 4 3 3 3 4 3 3 3 4 3 3 4 3 3 3 4 5 4 3 4 3 3 3 4 3 3 3 4 5 4 3 4 3 3 4 3 3 3 4 5 6 5 4 5 4 4 3 4 5 4 3 4 3 3 3 4 5 4 3 4 3 3 3 4 3 3 3 4 5 6 5 4 5 4 3 4 5 4 3 4 3 3 4 5 4 3 4 3 3 4 3 3 3 4 5 6 7 6 5 6 5 5 4 5 6 5 4 5 4 4 3 4 5 6 5 4 5 4 4 3 4 5 4 3 4 3 3 3 4 5 6 5 4 5 4 4 3 4 5 4 3 4 3 3 3 4 5 4 3 4 3 3 3 4 3 3 3 4 5 6 7 8 7 6 7 6 6 5 6 7 6 5 6 5 5 4 5 6 7 6 5 6 5 5 4 5 6 5 4 5 4 4 3 4 5 6 7 6 5 6 5 5 4 5 6 5 4 5 4 4 3 4 5 6 5 4 5 4 4 3 4 5 4 3 4 3 3 3 4 5 6 7 6 5 6 5 5 4 5 6 5 4 5 4 4 3 4 5 6 5 4 5 4 4 3 4 5 4 3 4 3 3 3 4 5 6 5 4 5 4 4 3 4 5 4 3 4 3 3 3 4 5 4 3 4 3 3 3 4 3 3 3 4 5 6 7 8 9 8 7 8 7 7 6 7 8 7 6 7 6 6 5 6 7 8 7 6 7 6 6 5 6 7 6 5 6 5 5 4 5 6 7 8 7 6 7 6 6 5 6 7 6 5 6 5 5 4 5 6 7 6 5 6 5 5 4 5 6 5 4 5 4 4 3 4 5 6 7 8 7 6 7 6 6 5 6 7 6 5 6 5 5 4 5 6 7 6 5 6 5 5 4 5 6 5 4 5 4 4 3 4 5 6 7 6 5 6 5 5 4 5 6 5 4 5 4 4 3 4 5 6 5 4 5 4 4 3 4 5 4 3 4 3 3 3 4 5 6 7 8 7 6 7 6 6 5 6 7 6 5 6 5 5 4 5 6 7 6 5 6 5 5 4 5 6 5 4 5 4 4 3 4 5 6 7 6 5 6 5 5 4 5 6 5 4 5 4 4 3 4 5 6 5 4 5 4 4 3 4 5 4 3 4 3 3 3 4 5 6 7 6 5 6 5 5 4 5 6 5 4 5 4 4 3 4 5 6 5 4 5 4 4 3 4 5 4 3 4 3 3 3 4 5 6 5 4 5 4 4 3 4 5 4 3 4 3 3 3 4 5 4 3 4 3 3 3 4 3 3
## Largest clique: c(Samudra = 4, Idris = 6, Muklas = 1, Imron = 3, Dulmatin = 5, Azahari = 8, Ghoni = 9, Patek = 15, Sarijo = 17)
par(mfrow=c(1,2), mar=c(2,2,2,2))
plot(g, vertex.color = graph.coreness(g), edge.curved=0)
d. Communities
V(g)$color <- "gray"
V(g)['Amrozi']$color <- "green"
V(g)['Mubarok']$color <- "green"
V(g)['Arnasan']$color <- "salmon"
V(g)['Rauf']$color <- "salmon"
V(g)['Octavia']$color <- "salmon"
V(g)['Hidayat']$color <- "salmon"
V(g)['Junaedi']$color <- "salmon"
V(g)['Feri']$color <- "brown"
plot(g, edge.curved=0, main = "g: Communities")
#
par(mfrow=c(3,3), mar=c(2,2,2,2))
g <- simplify(g)
#Identifying communities using Girvan-Newman Edge Betweenness algorithm [for undirected graph only]
#Community structure detection based on the betweenness of the edges in the network
girvan_newman_communities_g <- edge.betweenness.community(g)
## Warning in edge.betweenness.community(g): At community.c:460 :Membership
## vector will be selected based on the lowest modularity score.
## Warning in edge.betweenness.community(g): At community.c:467 :Modularity
## calculation with weighted edge betweenness community detection might not
## make sense -- modularity treats edge weights as similarities while edge
## betwenness treats them as distances
#Identifying communities using Clauset Newman and Moore
#Community structure detection via fast greedy modularity optimization algorithm
#fast-greedy community finding works only on graphs without multiple edges
cnm_communities_g <- cluster_fast_greedy(g, merges = TRUE, modularity = TRUE, membership = TRUE)
#Identifying communities using Walktrap
#Community structure detection based on the random walks
walktrap_communities_g <- walktrap.community(g,modularity = TRUE)
plot(as.dendrogram(girvan_newman_communities_g), main="g: Girvan-NewMan")
plot(as.dendrogram(cnm_communities_g), main="g: CNM")
plot(as.dendrogram(walktrap_communities_g), main="g: Walktrap")