Sept11_nodes.csv and Sept11_links.csv.
library(tidyverse)
library(igraph) # This is the package to analyze the network
library(visNetwork) # Creates visualizations of the network
library(DT)
library(plotly)
Sept11_nodes <- read_csv("Sept11_nodes.csv")
Parsed with column specification:
cols(
id = [32mcol_double()[39m,
name = [31mcol_character()[39m
)
Sept11_links <- read_csv("Sept11_links.csv")
Parsed with column specification:
cols(
from = [32mcol_double()[39m,
to = [32mcol_double()[39m
)
Sept11_nodes %>%
datatable(rownames = F)
Sept11_links %>%
datatable(rownames = F)
visNetwork(Sept11_nodes, Sept11_links)
Sept11_network <- graph_from_data_frame(terrorist_links,
vertices = Sept11_nodes,
directed = F)
Sept11_network
IGRAPH 064181f UN-- 62 151 --
+ attr: name (v/c)
+ edges from 064181f (vertex names):
[1] Samir_Kashk --Essid_Sami_Ben_Khemais
[2] Madjid_Sahoune --Essid_Sami_Ben_Khemais
[3] Fahid_al_Shakri --Essid_Sami_Ben_Khemais
[4] Lased_Ben_Heni --Essid_Sami_Ben_Khemais
[5] Lased_Ben_Heni --Mohamed_Bensakhria
[6] Essid_Sami_Ben_Khemais--Seifallah_ben_Hassine
[7] Essid_Sami_Ben_Khemais--Mohamed_Bensakhria
[8] Essid_Sami_Ben_Khemais--Mehdi_Khammoun
+ ... omitted several edges
Sept11_network %>%
edge_density()
[1] 0.07985193
Sept11_network %>%
distances() %>%
datatable()
Sept11_network %>%
distances() %>%
as.vector() %>% # these two lines convert the distances matrix
as_tibble() %>% # to something plotly can graph
plot_ly(x = ~value) %>%
add_histogram()
Calling `as_tibble()` on a vector is discouraged, because the behavior is likely to change in the future. Use `enframe(name = NULL)` instead.
[90mThis warning is displayed once per session.[39m
Sept11_network %>%
get_diameter()
+ 6/62 vertices, named, from 064181f:
[1] Samir_Kashk Essid_Sami_Ben_Khemais
[3] Tarek_Maaroufi Abu_Qatada
[5] Abu_Walid Kamel_Daoudi
Sept11_network %>%
get_diameter() %>%
length()
[1] 6
Sept11_nodes <- terrorist_nodes %>%
mutate(label = name)
terrorist_nodes %>%
datatable()
Sept11_nodes <- terrorist_nodes %>%
mutate(title = name)
terrorist_nodes
Sept11_nodes <- Sept11_nodes %>%
mutate(degree = degree(Sept11_network))
Sept11_nodes %>%
arrange(-degree) %>%
datatable()
Sept11_network %>%
edge_betweenness()
[1] 61.000000 61.000000 61.000000 56.500000 4.500000
[6] 48.500000 47.500000 55.833333 48.500000 52.806777
[11] 57.500000 441.140110 12.500000 16.000000 5.166667
[16] 12.500000 64.333333 31.859890 23.666667 63.666667
[21] 44.416667 42.750000 46.333333 41.000000 19.333333
[26] 6.250000 61.000000 61.000000 61.000000 31.000000
[31] 9.000000 219.083333 25.250000 4.500000 74.250000
[36] 56.500000 59.815476 373.851190 18.547161 82.979396
[41] 40.342857 8.083333 9.083333 8.833333 36.078571
[46] 8.833333 16.816667 31.310256 20.657143 61.000000
[51] 61.000000 46.141617 3.375000 13.583333 6.849950
[56] 47.411905 3.250000 20.911905 34.916667 2.416667
[61] 14.583333 32.750000 2.166667 4.833333 12.416667
[66] 73.180506 83.666667 31.583333 29.580952 37.408283
[71] 43.691617 105.793998 56.587648 51.853968 66.749206
[76] 161.377778 251.854401 14.238889 2.250000 6.474950
[81] 43.288889 5.916667 6.552778 61.000000 6.000000
[86] 30.333333 6.000000 11.250000 7.575000 4.583333
[91] 11.167857 16.008333 15.013095 10.516667 24.728280
[96] 23.069048 8.203968 15.098413 48.930628 27.336580
[101] 35.373088 5.724950 3.400000 4.366667 8.891617
[106] 11.080253 19.711111 6.581746 47.742063 43.961111
[111] 22.041270 12.907215 16.096898 8.866667 23.402381
[116] 14.160714 24.339683 2.992857 13.387302 12.503968
[121] 10.872222 11.165079 25.895310 12.483333 9.824603
[126] 8.622619 32.086111 8.814286 7.550000 10.350000
[131] 15.405700 59.000000 36.597619 59.000000 27.166667
[136] 33.633333 29.945382 2.000000 2.000000 2.000000
[141] 24.283333 23.283333 6.133333 6.133333 53.866667
[146] 53.866667 61.000000 44.350000 41.128571 1.000000
[151] 4.166667
Sept11_links <- Sept11_links %>%
mutate(value =edge_betweenness(Sept11_network))
Sept11_links
visNetwork(Sept11_nodes,
Sept11_links,
main = "Network of Terrorists involved in the 2011 Terorist attack") %>%
visIgraphLayout(layout = "layout_nicely") %>%
visOptions(highlightNearest = T, nodesIdSelection = T)
Sept11_network %>%
infomap.community()
IGRAPH clustering infomap, groups: 6, mod: 0.51
+ groups:
$`1`
[1] "Imad_Eddin_Barakat_Yarkas"
[2] "Ramzi_Bin_al-Shibh"
[3] "Mohammed_Belfas"
[4] "Abdelghani_Mzoudi"
[5] "Ahmed_Khalil_Ibrahim_Samir_Al-Ani"
[6] "Mustafa_Ahmed_al-Hisawi"
[7] "Agus_Budiman"
[8] "Mounir_El_Motassadeq"
[9] "Zakariya_Essabar"
+ ... omitted several groups/vertices
Sept11_network %>%
infomap.community() %>%
membership()
Samir_Kashk
2
Madjid_Sahoune
2
Fahid_al_Shakri
2
Lased_Ben_Heni
2
Essid_Sami_Ben_Khemais
2
Seifallah_ben_Hassine
2
Mohamed_Bensakhria
2
Mehdi_Khammoun
2
Essoussi_Laaroussi
2
Tarek_Maaroufi
2
Haydar_Abu_Doha
2
Ahmed_Ressam
2
Abu_Qatada
3
Abu_Walid
3
Jean-Marc_Grandvisir
3
Abu_Zubeida
3
Mizar_Trabelsi
3
Djamal_Beghal
3
Kamel_Daoudi
3
Jerome_Courtaillier
3
David_Courtaillier
3
Zacarias_Moussaoui
3
Imad_Eddin_Barakat_Yarkas
1
Ramzi_Bin_al-Shibh
1
Mohammed_Belfas
1
Abdelghani_Mzoudi
1
Ahmed_Khalil_Ibrahim_Samir_Al-Ani
1
Mustafa_Ahmed_al-Hisawi
1
Agus_Budiman
1
Mounir_El_Motassadeq
1
Zakariya_Essabar
1
Mohamed_Atta
1
Fayez_Ahmed
1
Mamduh_Mahmud_Salim
1
Mamoun_Darkazanli
1
Said_Bahaji
1
Ziad_Jarrah
1
Marwan_Al-Shehhi
1
Wail_Alshehri
1
Waleed_Alshehri
1
Mohand_Alshehri
5
Satam_Suqami
1
Abdul_Aziz_Al-Omari
1
Lotfi_Raissi
6
Ahmed_Al_Haznawi
5
Raed_Hijazi
5
Nabil_al-Marabh
5
Hamza_Alghamdi
5
Ahmed_Alghamdi
5
Salem_Alhazmi
4
Hani_Hanjour
6
Bandar_Alhazmi
6
Rayed_Mohammed_Abdullah
6
Raisal_Al_Salmi
6
Majed_Moqed
4
Khalid_Al-Mihdhar
4
Nawaf_Alhazmi
4
Osama_Awadallah
4
Abdussattar_Shaikh
4
Mohamed_Abdi
4
Ahmed_Alnami
5
Saeed_Alghamdi
5
Sept11_nodes <- Sept11_nodes %>%
mutate(group = membership(infomap.community(Sept11_network)))
Sept11_nodes %>%
datatable()
visNetwork(Sept11_nodes,
Sept11_links,
main = "Network of Terrorists involved in the 2011 Terrorist Attack") %>%
visIgraphLayout(layout = "layout_nicely") %>%
visOptions(highlightNearest = T, nodesIdSelection = T)
visNetwork(Sept11_nodes,
Sept11_links,
main = "Network of Terrorists involved in the 2011 Terrorist Attack") %>%
visIgraphLayout(layout = "layout_nicely") %>%
visOptions(highlightNearest = T, nodesIdSelection = T, selectedBy = "group")