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")
── Column specification ──────────────────────────────────────────────────────────────────────────────────────
cols(
id = col_double(),
name = col_character()
)
Sept11_links <- read_csv("Sept11_links.csv")
── Column specification ──────────────────────────────────────────────────────────────────────────────────────
cols(
from = col_double(),
to = col_double()
)
Sept11_network <- graph_from_data_frame(Sept11_links,
vertices = Sept11_nodes,
directed = F)
Sept11_network
IGRAPH 8c51cbb UN-- 62 151 --
+ attr: name (v/c)
+ edges from 8c51cbb (vertex names):
[1] Samir_Kashk --Essid_Sami_Ben_Khemais Madjid_Sahoune --Essid_Sami_Ben_Khemais
[3] Fahid_al_Shakri --Essid_Sami_Ben_Khemais Lased_Ben_Heni --Essid_Sami_Ben_Khemais
[5] Lased_Ben_Heni --Mohamed_Bensakhria Essid_Sami_Ben_Khemais--Seifallah_ben_Hassine
[7] Essid_Sami_Ben_Khemais--Mohamed_Bensakhria Essid_Sami_Ben_Khemais--Mehdi_Khammoun
[9] Essid_Sami_Ben_Khemais--Essoussi_Laaroussi Essid_Sami_Ben_Khemais--Tarek_Maaroufi
[11] Essid_Sami_Ben_Khemais--Haydar_Abu_Doha Essid_Sami_Ben_Khemais--Mohamed_Atta
[13] Seifallah_ben_Hassine --Tarek_Maaroufi Mohamed_Bensakhria --Tarek_Maaroufi
[15] Mehdi_Khammoun --Haydar_Abu_Doha Essoussi_Laaroussi --Tarek_Maaroufi
+ ... omitted several edges
This shows the network of terrorists on sept 11.
Sept11_network %>%
edge_density()
[1] 0.07985193
the density of the Sept 11 network is .08
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()
A hsitogram showing distances between the netowrk.
Sept11_network %>%
get_diameter() %>%
length()
[1] 6
6 is the diameter length.
Sept11_nodes<- Sept11_nodes%>%
mutate(label= name)
Sept11_nodes<- Sept11_nodes%>%
mutate(title= name)
Sept11_nodes<- Sept11_nodes%>%
mutate(degree= degree(Sept11_network))
Sept11_nodes<- Sept11_nodes%>%
mutate(value= degree)
Sept11_nodes%>%
datatable()
This is a data table showing all the items that I mutated.
Sept11_links <- Sept11_links %>%
mutate (betweenness = edge_betweenness(Sept11_network)) %>%
mutate(value = betweenness)
Sept11_links%>%
datatable()
This is a datatable showing the mutation between value and betweenness.
visNetwork(Sept11_nodes,
Sept11_links,
main = "Network of Terrorists involved in the 9/11 attack") %>%
visIgraphLayout(layout = "layout_nicely") %>%
visOptions(highlightNearest = T)
This is a visdiagram showing the network of terrorists involved in the Sept 11 attack.
Sept11_network %>%
infomap.community()
IGRAPH clustering infomap, groups: 6, mod: 0.51
+ groups:
$`1`
[1] "Imad_Eddin_Barakat_Yarkas" "Ramzi_Bin_al-Shibh"
[3] "Mohammed_Belfas" "Abdelghani_Mzoudi"
[5] "Ahmed_Khalil_Ibrahim_Samir_Al-Ani" "Mustafa_Ahmed_al-Hisawi"
[7] "Agus_Budiman" "Mounir_El_Motassadeq"
[9] "Zakariya_Essabar" "Mohamed_Atta"
[11] "Fayez_Ahmed" "Mamduh_Mahmud_Salim"
[13] "Mamoun_Darkazanli" "Said_Bahaji"
[15] "Ziad_Jarrah" "Marwan_Al-Shehhi"
[17] "Wail_Alshehri" "Waleed_Alshehri"
+ ... omitted several groups/vertices
Sept11_nodes <- Sept11_nodes %>%
mutate(group = membership(infomap.community(Sept11_network)))
Sept11_nodes %>%
datatable()
NA
visNetwork(Sept11_nodes,
Sept11_links,
main = "Network of Terrorists involved in the 9/11 bombing") %>%
visIgraphLayout(layout = "layout_nicely") %>%
visOptions(highlightNearest = T, nodesIdSelection = T, selectedBy = "group")
Here is the mutated data and the diagram.